/*
 * 商品列表
 * @Author: ice
 * @Date: 2018-11-02 09:12:52
 * @Last Modified by: along
 * @Last Modified time: 2020-07-14
 */

<template>
    <div class="container goods-list-container">
        <div class="container-header">
            <div class="header-goods-list">
                <div class="header-title">商品列表</div>
                <div class="opt-btn-group">
                    <div
                        class="opt-btn-item"
                        @click="handleRoute('noSettleGoodsList')"
                    >
                        无需结算商品
                    </div>
                    <div
                        class="opt-btn-item"
                        @click="fnGoAcquisitoin()"
                    >
                        采集
                    </div>
                    <div
                        class="opt-btn-item"
                        @click="fnGoWorkBrowse(1)"
                    >
                        销量自增长管理
                    </div>
                    <div
                        class="opt-btn-item"
                        @click="fnGoWorkBrowse(2)"
                    >
                        浏览量自增长管理
                    </div>
                    <div
                        class="opt-btn-item"
                        @click="fnImport()"
                    >
                        导入淘客商品
                    </div>
                </div>
            </div>
        </div>
        <!-- 筛选-->
        <div class="filter-view">
            <div class="header-new-box">
                <el-radio-group
                    v-model="filterData.goods_type"
                    size="small"
                    @change="getTableData(1)"
                >
                    <el-radio-button
                        v-for="item in goodsTypeList"
                        :key="item.value"
                        :label="item.value"
                    >
                        {{ item.label }}
                    </el-radio-button>
                </el-radio-group>
            </div>
            <div class="header-new-box">
                <p class="header-new-box-title">商品名称</p>
                <el-input
                    placeholder="商品名称"
                    v-model="filterData.goods_title"
                    suffix-icon="el-icon-search"
                    clearable
                    size="small"
                    @keydown.enter.native="getTableData(1)"
                />
            </div>
            <div class="header-new-box">
                <p class="header-new-box-title">商品编号</p>
                <el-input
                    placeholder="商品编号"
                    v-model="filterData.goods_no"
                    suffix-icon="el-icon-search"
                    clearable
                    size="small"
                    @keydown.enter.native="getTableData(1)"
                />
            </div>
            <div class="header-new-box">
                <p class="header-new-box-title">店铺名称</p>
                <el-input
                    placeholder="店铺名称"
                    v-model="filterData.shop_title"
                    suffix-icon="el-icon-search"
                    clearable
                    size="small"
                    @keydown.enter.native="getTableData(1)"
                />
            </div>
            <div class="header-new-box">
                <p class="header-new-box-title">店铺编号</p>
                <el-input
                    placeholder="店铺编号"
                    v-model="filterData.shop_no"
                    suffix-icon="el-icon-search"
                    clearable
                    size="small"
                    @keydown.enter.native="getTableData(1)"
                />
            </div>
            <div class="header-new-box">
                <p class="header-new-box-title">商品分类</p>
                <el-cascader
                    placeholder="请选择"
                    :options="typeList"
                    filterable
                    clearable
                    size="small"
                    change-on-select
                    expand-trigger="click"
                    v-model="filterData.selectedType"
                    :props="{
                        label: 'title',
                        value: 'no',
                        children: 'children'
                    }"
                    style="width: 100%"
                    @change="getTableData(1)"
                />
            </div>
            <template v-if="!isFold">
                <div class="header-new-box">
                    <p class="header-new-box-title">
                        商品平台
                    </p>
                    <el-select
                        v-model="filterData.shop_social_type"
                        size="small"
                        filterable
                        style="width: 152px"
                        @change="getTableData(1)"
                    >
                        <el-option
                            label="全部"
                            :value="99"
                        />
                        <el-option
                            label="淘宝"
                            :value="1"
                        />
                        <el-option
                            label="京东"
                            :value="2"
                        />
                        <el-option
                            label="拼多多"
                            :value="3"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">审核状态</p>
                    <el-select
                        clearable
                        class="filter-input"
                        v-model="filterData.audit_status"
                        filterable
                        size="small"
                        @change="getTableData(1)"
                        placeholder="请选择"
                    >
                        <el-option
                            v-for="item in audioList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">上架状态</p>
                    <el-select
                        clearable
                        class="filter-input"
                        v-model="filterData.goods_status"
                        filterable
                        size="small"
                        placeholder="请选择"
                        @change="getTableData(1)"
                    >
                        <el-option
                            v-for="item in goodsList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">淘客商品编号</p>
                    <el-input
                        placeholder="淘客商品编号"
                        v-model="filterData.item_id"
                        suffix-icon="el-icon-search"
                        clearable
                        size="small"
                        @keydown.enter.native="getTableData(1)"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">淘客佣金</p>
                    <el-input
                        class="number-input-number"
                        clearable
                        v-model="filterData.commission_money_range"
                        :min="0"
                        style="width: 130px"
                        size="small"
                        type="number"
                    />
                    <span style="margin: 0 6px">-</span>
                    <el-input
                        class="number-input-number"
                        clearable
                        v-model="filterData.commission_money_rangeEnd"
                        :min="0"
                        style="width: 130px"
                        size="small"
                        type="number"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">商品组</p>
                    <el-select
                        v-model="filterData.cate_no_type"
                        filterable
                        clearable
                        size="small"
                        placeholder="请选择"
                        @change="getTableData(1)"
                    >
                        <el-option
                            v-for="item in typeAllListType"
                            :key="item.cate_no"
                            :label="item.cate_name"
                            :value="item.cate_no"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">商品组精选</p>
                    <el-select
                        v-model="filterData.set_cate_recommend"
                        placeholder="请选择"
                        size="small"
                        @change="fnSetCate"
                    >
                        <el-option
                            label="全部"
                            value=""
                        /><el-option
                            label="是"
                            :value="1"
                        /><el-option
                            label="否"
                            :value="0"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">销量自增长</p>
                    <el-select
                        v-model="volume"
                        placeholder="请选择"
                        size="small"
                        @change="getTableData(1)"
                    >
                        <el-option
                            v-for="item in volumeList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">浏览量增长</p>
                    <el-select
                        v-model="autoinc_view_set"
                        placeholder="请选择"
                        size="small"
                        @change="getTableData(1)"
                    >
                        <el-option
                            v-for="item in volumeList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">学校权限</p>
                    <el-select
                        v-model="school_filter_status"
                        placeholder="请选择"
                        size="small"
                        @change="getTableData(1)"
                    >
                        <el-option
                            v-for="item in filterAuthList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
            </template>
            <div class="header-new-box">
                <el-button
                    type="primary"
                    size="small"
                    @click="getTableData(1)"
                >
                    搜索
                </el-button>
                <el-button
                    type="primary"
                    size="small"
                    @click="fnReset"
                >
                    重置
                </el-button>
                <el-button
                    type="primary"
                    size="small"
                    @click="isFold = !isFold"
                >
                    {{ isFold ? '展开' : '收起' }}
                    <i :class="isFold ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"/>
                </el-button>
            </div>
        </div>
        <!--筛选-->
        <div class="content-wrapper">
            <div class="table-wrapper">
                <el-table
                    :data="tableData"
                    height="100%"
                    style="width: 100%;"
                    ref="goodsTable"
                    class="data-table"
                    @sort-change="handleSortChanged"
                    @select="fnSelect"
                    @select-all="fnSelectAllTop"
                    @selection-change="handleSelectionChange"
                    v-loading="loadingData"
                >
                    <el-table-column
                        type="selection"
                        width="40"
                        fixed="left"
                    />
                    <el-table-column
                        width="320"
                        label="商品信息"
                        fixed="left"
                    >
                        <template slot-scope="scope">
                            <div class="goods-info">
                                <img
                                    :src="scope.row.goods_cover"
                                    class="goods-cover"
                                    @click="fnShowPreview(scope.row.goods_cover)"
                                >
                                <div class="info">
                                    <div
                                        class="goods-info__title shop-item-jump"
                                        @click="fnGoShoplist(scope.row)"
                                    >
                                        {{ scope.row.goods_title }}
                                    </div>
                                    <div class="goods-info__no">
                                        商品编号：{{ scope.row.goods_no }}
                                    </div>
                                    <div class="goods-info__shop-title">
                                        店铺名称：{{ scope.row.shop_title }}
                                    </div>
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="商品单价"
                        :formatter="emptyFormatter"
                        prop="goods_price"
                        width="110"
                        align="center"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.goods_price }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="商品平台"
                        align="center"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            {{ scope.row.shop_social_type | socialFilter }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_price_origin"
                        width="130"
                        label="平台售价"
                        align="center"
                        sortable="custom"
                        :render-header="renderHeader"
                    />
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_commission"
                        label="佣金"
                        sortable="custom"
                    />
                    <el-table-column
                        prop="reduction_info"
                        :formatter="emptyFormatter"
                        label="优惠力度"
                    >
                        <template slot-scope="scope">
                            <div class="cursor-font">
                                <el-popover
                                    placement="left"
                                    :width="scope.row.reduction_info.list.length == 0 ? 120 :'auto'"
                                >
                                    <div
                                        v-if="scope.row.reduction_info.list.length > 0"
                                        :style="{width: '100%', textAlign: 'center', display: 'flex', flexDirection: 'column'}"
                                    >
                                        <div :style="{height: '28px', display: scope.row.reduction_info.list.length > 1 ? 'flex' : '', alignItems: 'center'}">
                                            <div
                                                v-for="(item, index) in scope.row.reduction_info.list"
                                                :key="index"
                                            >
                                                <div
                                                    v-if="index <= 2"
                                                    class="reduction_price"
                                                    :style="{color: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', borderColor: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', margin: index == 1 ? (scope.row.reduction_info.list.length == 2 ? '0 0 0 12px' : '12px') : '0'}"
                                                >
                                                    满{{ item.require_num }}{{ scope.row.reduction_info.reduction_type == 2 ? '' : '件' }}减{{ item.reduction_price }}
                                                </div>
                                            </div>
                                        </div>
                                        <div
                                            :style="{height: '28px', display: 'flex', alignItems: 'center', marginTop: '18px'}"
                                            v-if="scope.row.reduction_info.list.length > 3"
                                        >
                                            <div
                                                v-for="(item, index) in scope.row.reduction_info.list"
                                                :key="index"
                                            >
                                                <div
                                                    v-if="index > 2"
                                                    class="reduction_price"
                                                    :style="{color: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', borderColor: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', margin: index == 4 ? (scope.row.reduction_info.list.length == 5 ? '0 0 0 12px' : '12px') : '0'}"
                                                >
                                                    满{{ item.require_num }}{{ scope.row.reduction_info.reduction_type == 2 ? '' : '件' }}减{{ item.reduction_price }}
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div
                                        v-else
                                        :style="{width: '100%', textAlign: 'center'}"
                                    >
                                        暂无数据
                                    </div>
                                    <el-button
                                        slot="reference"
                                        type="text"
                                    >
                                        查看
                                    </el-button>
                                </el-popover>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="goods_commission_rate"
                        width="110"
                        label="佣金比例"
                    >
                        <template slot-scope="scope">
                            <div class="comp">
                                <template v-if="scope.row.goods_type == 2">
                                    {{ scope.row.goods_commission_rate | commissionRateFilter }}
                                </template>
                                <template v-else>
                                    <el-popover
                                        placement="bottom"
                                        trigger="click">
                                        <div
                                            class="spec-list"
                                            v-if="scope.row.specList">
                                            <div
                                                class="spec-line"
                                                v-for="(specItem, specIndex) in scope.row.specList"
                                                :key="specIndex">
                                                {{ specItem | specFilter }}
                                            </div>
                                        </div>
                                        <el-button
                                            slot="reference"
                                            type="text"
                                            @mouseover.native="fnGetSpec(scope.row)">查看</el-button>
                                    </el-popover>
                                </template>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="coupon_money"
                        width="110"
                        label="优惠券"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.coupon_money }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column>
                    <!-- <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_price_pay"
                        width="110"
                        label="学生价"
                        sortable="custom"
                        :render-header="renderHeaderPay"
                    /> -->

                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_freight"
                        width="110"
                        label="运费设置"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.goods_freight }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="goods_type"
                        show-overflow-tooltip
                        width="110"
                        label="商品种类"
                    >
                        <template slot-scope="scope">
                            <span>{{ scope.row.goods_type | setGoodsType }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="type_name"
                        width="110"
                        label="商品分类"
                    />
                    <el-table-column
                        prop="sub_type_name"
                        width="110"
                        label="二级分类"
                    >
                        <template slot-scope="scope">
                            <p
                                @click="fnSetTypename(scope.row)"
                                style="cursor:pointer"
                            >
                                <span>{{ scope.row.sub_type_name }}</span>
                                <i
                                    v-if="scope.row.sub_type_name !== '--'"
                                    class="el-icon-edit"
                                />
                            </p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="agent_cate_name"
                        label="所属代理类目"
                        :width="150"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                    >
                        <template slot-scope="scope">
                            <p
                                class="cursor-font"
                                @click="fnSetAgent(scope.row)"
                            >
                                {{ scope.row.agent_cate_name ? scope.row.agent_cate_name : '--' }}
                            </p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="school_filter_status"
                        label="是否设置学校权限"
                        show-overflow-tooltip
                        :width="150"
                        :formatter="emptyFormatter"
                    >
                        <template slot-scope="scope">
                            <p
                                v-if="scope.row.school_filter_status == 1"
                                @click="fnSetAuthor(scope.row)"
                                class="cursor-font"
                            >是</p>
                            <p v-if="scope.row.school_filter_status == 0">否</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable="custom"
                        prop="goods_sort"
                        label="排序"
                    >
                        <template slot-scope="scope">
                            <div class="sort-wrap">
                                {{ scope.row.goods_sort }}
                                <span class="sort-spliter" />
                                <el-button
                                    type="text"
                                    class="btn-sort"
                                    @click="fnEditSort(scope.row, 'goods_sort')"
                                >
                                    <i class="el-icon-edit" />
                                </el-button>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable="custom"
                        prop="goods_sale"
                        label="真实销量"
                        width="110"
                    />
                    <el-table-column
                        sortable="custom"
                        prop="goods_sale_base"
                        width="110"
                        label="商品销量"
                    >
                        <template slot-scope="scope">
                            <div class="sort-wrap">
                                {{ scope.row.goods_sale_base }}
                                <span class="sort-spliter" />
                                <el-button
                                    type="text"
                                    class="btn-sort"
                                    @click="fnEditSort(scope.row, 'goods_sale_base')"
                                >
                                    <i class="el-icon-edit" />
                                </el-button>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        header-align="left"
                        prop="autoinc_sale"
                        align="center"
                        width="200"
                        label="是否销量自增长"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <p
                                v-if="scope.row.goods_type == 1 || scope.row.goods_type == 4"
                            >
                                <span v-if="scope.row.autoinc_sale.autoinc_no == ''">
                                    否
                                </span>
                                <span v-if="scope.row.autoinc_sale.autoinc_no !== ''">
                                    是（{{ scope.row.autoinc_sale.inc_count_min ? scope.row.autoinc_sale.inc_count_min * 24 : 0 }} - {{ scope.row.autoinc_sale.inc_count_max ? scope.row.autoinc_sale.inc_count_max * 24 : 0 }} 个/天）
                                </span>
                            </p>
                            <p v-else>--</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_view"
                        width="110"
                        label="商品浏览量"
                    />
                    <el-table-column
                        header-align="left"
                        prop="autoinc_view"
                        align="center"
                        width="200"
                        label="是否浏览量自增长"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <p
                                v-if="scope.row.goods_type == 1 || scope.row.goods_type == 4"
                            >
                                <span v-if="scope.row.autoinc_view.autoinc_no == ''">
                                    否
                                </span>
                                <span v-if="scope.row.autoinc_view.autoinc_no !== ''">
                                    是（{{ scope.row.autoinc_view.inc_count_min ? scope.row.autoinc_view.inc_count_min * 24 : 0 }} - {{ scope.row.autoinc_view.inc_count_max ? scope.row.autoinc_view.inc_count_max * 24 : 0 }} 个/天）
                                </span>
                            </p>
                            <p v-else>--</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="create_time"
                        width="140"
                        label="创建时间"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.create_time">{{ scope.row.create_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="shelf_time"
                        width="140"
                        label="上架时间"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.shelf_time">{{ scope.row.shelf_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="expire_time"
                        width="140"
                        label="下架时间"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.expire_time">{{ scope.row.expire_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="hire_settle_status"
                        width="110"
                        label="是否入驻商城"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.hire_settle_status == 1">已入驻</span>
                            <span
                                v-if="scope.row.hire_settle_status == 0"
                                style="color: #F95B56"
                            >
                                未入驻
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="audit_status"
                        width="100"
                        label="审核状态"
                    >
                        <template slot-scope="scope">
                            <div class="task-review-status">
                                <template v-if="scope.row.audit_status == -1">
                                    <span class="status deny">审核不通过</span>
                                </template>
                                <template v-if="scope.row.audit_status == 0">
                                    <span class="status wait-submit">待审核</span>
                                </template>
                                <template v-if="scope.row.audit_status == 1">
                                    <span class="status completed">审核通过</span>
                                </template>
                            </div>
                        </template>
                    </el-table-column>

                    <el-table-column
                        prop="goods_status"
                        width="100"
                        label="上架状态"
                    >
                        <template slot-scope="scope">
                            <el-switch
                                v-model="scope.row.goods_status"
                                :disabled="scope.row.audit_status != 1"
                                :active-value="1"
                                :inactive-value="0"
                                @change="fnSetStatus(scope.row)"/>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable="custom"
                        prop="cate_type_goods_sort"
                        label="商品组分类商品排序"
                        v-if="groupType == 2"
                        :width="180"
                    >
                        <template slot-scope="scope">
                            <div class="sort-wrap">
                                {{ scope.row.cate_type_goods_sort }}
                                <span class="sort-spliter" />
                                <el-button
                                    type="text"
                                    class="btn-sort"
                                    @click="fnEditSortCate(scope.row, 'cate_type_goods_sort')"
                                >
                                    <i class="el-icon-edit" />
                                </el-button>
                            </div>
                        </template>
                    </el-table-column>

                    <!-- <el-table-column
                        :formatter="emptyFormatter"
                        prop="tuan_num"
                        width="110"
                        label="成团人数"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.tuan_num }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column> -->

                    <el-table-column
                        :formatter="emptyFormatter"
                        v-if="filterData.goods_type == '4' "
                        prop="goods_price"
                        width="110"
                        label="商圈优惠价"
                    />
                    <el-table-column
                        prop="cate_type_names"
                        label="商品组分类"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        :width="110"
                        fixed="right"
                        v-if="groupType"
                    >
                        <template slot-scope="scope">
                            <p v-if="scope.row.cate_type_names">
                                {{ scope.row.cate_type_names }}
                            </p>
                            <p v-else>
                                无分类
                            </p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="date"
                        label="操作"
                        width="220"
                        fixed="right"
                    >
                        <template slot-scope="scope">
                            <div class="option-btn-group">
                                <el-button
                                    type="text"
                                    class="btn-delete"
                                    @click="fnDeleteGoods(scope.row)">删除</el-button>
                                <!-- <el-button
                                    type="text"
                                    class="zd-btn-text"
                                    v-if="showCancelJingang"
                                    @click="removeJingang(scope.row.goods_no)">移出此栏目</el-button> -->
                                <el-button
                                    type="text"
                                    v-if="scope.row.goods_type == 1 || scope.row.goods_type == 4 "
                                    @click="fnJump(scope.row.goods_no)">问答</el-button>
                                <!-- 自营商品会有审核操作 -->
                                <template v-if="scope.row.goods_type == 1 || scope.row.goods_type == 8">
                                    <el-button
                                        type="text"
                                        :disabled="scope.row.audit_status == 1 || scope.row.hire_settle_status == 0"
                                        @click="fnAudit(scope.row, 1)">审核通过</el-button>
                                    <el-button
                                        type="text"
                                        :disabled="scope.row.audit_status == -1"
                                        @click="fnAudit(scope.row, -1)">审核不通过</el-button>
                                </template>
                                <el-button
                                    type="text"
                                    @click="fnLabel(scope.row)">打标签</el-button>
                                <el-button
                                    type="text"
                                    @click="fnSetAuthor(scope.row)">设置学校权限</el-button>
                                <el-button
                                    type="text"
                                    v-if="scope.row.cate_recommend == 0 && is_cate"
                                    @click="fnSetCateRecommend(scope.row, 1)">设为精选</el-button>
                                <el-button
                                    type="text"
                                    v-if="scope.row.cate_recommend == 1 && is_cate"
                                    @click="fnSetCateRecommend(scope.row, 0)">取消精选</el-button>
                                <el-button
                                    type="text"
                                    v-if="groupType"
                                    @click="fnEditGroup(scope.row)">编辑商品组</el-button>
                                <el-button
                                    type="text"
                                    v-if="groupType == 1"
                                    @click="fnRemoveGroup(scope.row)">移出商品组</el-button>
                                <el-button
                                    type="text"
                                    v-if="groupType == 2"
                                    @click="fnRemoveGroupChild(scope.row)">移出此分类</el-button>
                                <el-button
                                    type="text"
                                    @click="goMaterialList(scope.row)">查看素材库</el-button>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="pagination-wrapper clearfix">
                <div class="el-pagage-wrap">
                    <div class="el-page-box">
                        <el-checkbox
                            v-model="checkedAll"
                            :indeterminate="checkIndeterminate"
                            @change="fnChangeChecked">全选</el-checkbox>
                        <div class="el-pagage-cont">
                            <el-dropdown
                                :hide-on-click="false"
                                :class="multipleSelection.length == 0 ? '' : 'el-pagage-cursor'"
                                @command="handleCommand"
                            >
                                <span class="el-dropdown-link">
                                    商品批量操作选项
                                </span>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item
                                        v-for="(item,index) in menuList"
                                        :key="index"
                                        :command="item"
                                    >
                                        {{ item }}
                                    </el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown>
                        </div>
                    </div>
                    <el-pagination
                        layout="total,sizes, prev, pager, next, jumper"
                        background
                        :current-page.sync="page.now_page"
                        :total="page.total_count"
                        :page-size="page.page_size"
                        @current-change="getTableData"
                        @size-change="handleSizeChange"
                    />
                </div>
            </div>

            <!-- 打标签 -->
            <el-dialog
                :visible.sync="mergeDialogVisible"
                center
                :before-close="fnBeforeColse"
            >
                <div class="content-dialog">
                    <el-select
                        v-model="label"
                        filterable
                        placeholder="创建或者搜索标签"
                        class="label-input"
                        :allow-create="true"
                        default-first-option
                        @change="handleLabelSelect"
                        @focus="fnClearLabel"
                        ref="labelClear"
                        @keyup.native.enter="handleLabelEnter"
                    >
                        <el-option
                            v-for="item in restaurants"
                            :key="item.tag_no"
                            :label="item.name"
                            :value="item"
                        />
                    </el-select>
                    <div class="label">
                        <el-tag
                            v-for="(tag,index) in labelList"
                            :key="index"
                            closable
                            :disable-transitions="false"
                            @close="handleClose(tag,index)"
                        >
                            {{ tag }}
                        </el-tag>
                    </div>
                    <div class="label-default">
                        <div
                            v-for="(item,index) in defaultLabel"
                            :key="index"
                        >
                            <div
                                class="label-cont"
                                v-if="item['tag_list'].length == 0 ? false : true "
                            >
                                <p class="label-title">{{ item.group_name }}</p>
                                <p
                                    class="label-refresh"
                                    @click="fnlabelRefresh(item.group_no)"
                                >
                                    <i class="el-icon-refresh-right"/>
                                    <span style="margin-right:15px">换一批</span>
                                </p>
                            </div>
                            <el-tag
                                v-for="(tag,idx) in item['tag_list']"
                                :key="idx"
                                type="info"
                                :disable-transitions="false"
                                @click="fnGetLabel(tag)"
                            >
                                {{ tag.name }}
                            </el-tag>
                        </div>
                    </div>
                    <p
                        class="label-tips"
                        v-if="isLabel"
                    >暂无内容</p>
                    <span
                        slot="footer"
                        class="dialog-footer"
                    >
                        <el-button
                            size="small"
                            @click="fnLabelCancel">取 消</el-button>
                        <el-button
                            type="primary"
                            size="small"
                            @click="submitFormMerge">确 定</el-button>
                    </span>
                </div>
            </el-dialog>
            <!-- /打标签 -->

            <!-- 新建标签弹窗 -->
            <el-dialog
                :visible.sync="centerDialogVisible"
                width="660px"
                height="400px !important"
                center
            >
                <el-form
                    :model="ruleFormLabel"
                    :rules="rulesLabel"
                    ref="ruleFormLabel"
                    label-width="100px"
                    class="demo-ruleForm"
                >
                    <el-form-item
                        label="选择类型"
                        prop="type"
                    >
                        <el-button
                            :type="ruleFormLabel['type'] == 1 ? 'primary' : '' "
                            size="small"
                            class="header-label"
                            :disabled="true"
                            @click="fnSelectType('user')"
                        >用户</el-button>
                        <el-button
                            :type="ruleFormLabel['type'] == 1 ? '' : 'primary' "
                            size="small"
                            class="header-label"
                            @click="fnSelectType('shop')"
                        >商品</el-button>
                    </el-form-item>
                    <el-form-item
                        label="选择分类"
                        prop="label"
                        ref='labelType'
                    >
                        <el-select
                            v-model="ruleFormLabel.label"
                            filterable
                            placeholder="请选择"
                            @change="handleSelectLabel"
                            :style="{width:'100%'}"
                        >
                            <el-option
                                v-for="item in ificationLabelList"
                                :key="item.group_no"
                                :label="item.name"
                                :value="item.group_no"
                            />
                        </el-select>
                    </el-form-item>

                    <el-form-item
                        label="新建标签"
                        prop="tag"
                    >
                        <el-input
                            v-model="ruleFormLabel.tag"
                            size="small"
                        />
                    </el-form-item>
                </el-form>
                <span
                    slot="footer"
                    class="dialog-footer"
                >
                    <el-button
                        size="small"
                        @click="centerDialogVisible = false">取 消</el-button>
                    <el-button
                        type="primary"
                        size="small"
                        @click="submitFormLabel('ruleFormLabel')">保 存</el-button>
                </span>
            </el-dialog>
            <!-- 新建/编辑弹窗 -->

            <el-dialog
                title="设置商品组"
                width="530px"
                custom-class="schedule-dialog"
                :visible.sync="showJingangDialog">
                <div class="cate-area">
                    <el-checkbox-group v-model="checkedJingang">
                        <el-checkbox
                            class="cate-area-item"
                            :label="citem.no"
                            v-for="(citem, cindex) in cateList"
                            :key="cindex">{{ citem.title }}</el-checkbox>
                    </el-checkbox-group>
                </div>
                <div
                    slot="footer"
                    class="dialog-footer">
                    <el-button
                        size="small"
                        class="dialog-rel"
                        @click="showJingangDialog = false">取 消</el-button>
                    <el-button
                        size="small"
                        type="primary"
                        @click="fnPushJingang">确 定</el-button>
                </div>
            </el-dialog>

            <!-- 导入淘客 -->
            <el-dialog
                title="导入客户淘客"
                width="530px"
                custom-class="schedule-dialog"
                :visible.sync="showAddDialog"
            >
                <el-form
                    :model="ruleForm"
                    :rules="rules"
                    ref="ruleForm"
                    class="demo-ruleForm"
                    label-width="100px"
                >
                    <el-form-item label="商品平台">
                        <el-radio-group v-model="ruleForm.shop_social_type">
                            <el-radio :label="1">淘宝</el-radio>
                            <el-radio :label="2">京东</el-radio>
                            <el-radio :label="3">拼多多</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item
                        label="店铺名称"
                        prop="shop_no"
                    >
                        <el-select
                            v-model="ruleForm.shop_no"
                            filterable
                            remote
                            placeholder="请输入客户的店铺名称"
                            :remote-method="fnSearchShop"
                            @change="handleSelect"
                            :loading="loading"
                            size="small"
                            style="width:315px"
                        >
                            <el-option
                                v-for="item in shopListChoose"
                                :key="item.shop_no"
                                :label="item.shop_title"
                                :value="item.shop_no"/>
                        </el-select>
                        <el-popover
                            placement="bottom-start"
                            width="280"
                            trigger="hover"
                            content="导入客户商品时，如该客户已有店铺，则需导入至该客户的已有店铺中去，以防出现多个店铺的情况">
                            <el-button
                                slot="reference"
                                type="text"
                            >
                                <span
                                    class="iconfont el-icon-hand-ziyuan"
                                    :style="{'color': '#606266'}"
                                />
                            </el-button>
                        </el-popover>
                    </el-form-item>
                    <el-form-item
                        label="商品链接"
                        prop="url"
                    >
                        <el-input
                            type="textarea"
                            :autosize="{ minRows: 2, maxRows: 6}"
                            v-model="ruleForm.url"
                            placeholder="请输入商品链接"
                            size="small"
                        />
                    </el-form-item>
                    <el-form-item
                        label="商品分类"
                        prop="fication"
                    >
                        <el-cascader
                            placeholder="请选择商品分类"
                            :options="typeAllList"
                            filterable
                            clearable
                            size="small"
                            expand-trigger="click"
                            v-model="ruleForm.fication"
                            :props="{
                                label: 'title',
                                value: 'no',
                                children: 'children'
                            }"
                            style="width: 350px"
                        />
                    </el-form-item>
                </el-form>
                <div
                    slot="footer"
                    class="dialog-footer"
                >
                    <el-button
                        size="small"
                        type="primary"
                        @click="submitForm('ruleForm')">提交</el-button>
                </div>
            </el-dialog>
            <!-- /导入淘客 -->

            <!-- 添加0元购提示信息 -->
            <el-dialog
                :visible.sync="dialogVisibleList"
                width="860px"
                :close-on-click-modal="false"
                class="shopAdd_result"
            >
                <p class="shop_tips_title">*只能推荐淘礼金金额 - 佣金金额小于等于5元，且已上架的淘客商品</p>
                <el-table
                    :data="tableDateResh"
                    height="100%"
                    style="width: 100%;"
                    border
                >
                    <el-table-column
                        label="序号"
                        type=index
                        :width="60"
                    />
                    <el-table-column
                        prop="goods_no"
                        label="商品编号"
                        show-overflow-tooltip
                        align="center"
                        :width="140"
                    />
                    <el-table-column
                        prop="msg_info"
                        label="商品信息"
                        show-overflow-tooltip
                        align="center"
                    />
                    <el-table-column
                        prop="msg_code"
                        label="添加结果"
                        show-overflow-tooltip
                        align="center"
                        :width="100"
                    >
                        <template slot-scope="scope">
                            <span
                                v-if="scope.row.msg_code == 1"
                                class="shop_addInfo_sucess"
                            >成功</span>
                            <span
                                v-if="scope.row.msg_code == 0"
                                class="shop_addInfo_error"
                            >失败</span>
                        </template>
                    </el-table-column>
                </el-table>
            </el-dialog>
            <!-- /添加0元购提示信息 -->

            <!-- 设置商品自动增长 -->
            <el-dialog
                title="自动增长量"
                :visible.sync="dialogVisiblBrowse"
                width="510px"
            >
                <div style="display:flex">
                    <p style="white-space: nowrap">
                        选择规则:
                    </p>
                    <div style="display:flex;flex-wrap:wrap">
                        <div
                            style="marginBottom: 15px;marginLeft:30px;"
                            v-for="(item,index) in browseList"
                            :key="index"
                        >
                            <el-radio
                                v-model="browse"
                                :label="item.autoinc_no"
                            >
                                <span>{{ item.inc_count_min }} - {{ item.inc_count_max }}个/小时</span>
                            </el-radio>
                        </div>
                    </div>
                </div>
                <div style="display:flex;margin-top:24px">
                    <p style="white-space: nowrap">
                        选择规则:
                    </p>
                    <div style="display:flex;flex-direction: column;margin-left:30px">
                        <el-radio-group v-model="browseData.browse_type">
                            <el-radio :label="0">
                                不限制
                            </el-radio>
                            <el-radio :label="1">
                                <el-date-picker
                                    v-model="browseData.browse_date"
                                    type="datetimerange"
                                    :picker-options="browsePickerOptions()"
                                    range-separator="至"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期"
                                    align="right"
                                    size="small"
                                    :default-time="['00:00:00','23:59:59']"
                                    style="width:90%;margin-top:10px;"
                                />
                            </el-radio>
                        </el-radio-group>
                    </div>
                </div>
                <span
                    slot="footer"
                    class="dialog-footer">
                    <el-button
                        @click="dialogVisiblBrowse = false"
                        size="small"
                    >取 消</el-button>
                    <el-button
                        type="primary"
                        size="small"
                        @click="fnConfirmBrowse()">确 定</el-button>
                </span>
            </el-dialog>
            <!-- /设置商品自动增长 -->

            <!-- 修改分类 -->
            <el-dialog
                title="修改分类"
                :visible.sync="dialogVisibleTypeName"
                width="500px"
            >
                <div class="el-type-name">
                    <p style="marginRight: 10px;">分类</p>
                    <el-cascader
                        placeholder="请选择商品分类"
                        :options="typeAllList"
                        filterable
                        clearable
                        size="small"
                        expand-trigger="click"
                        v-model="type_name"
                        :props="{
                            label: 'title',
                            value: 'no',
                            children: 'children'
                        }"
                        style="width: 350px"
                    />
                </div>
                <span
                    slot="footer"
                    class="dialog-footer"
                >
                    <el-button
                        @click="dialogVisibleTypeName = false"
                        size="small"
                    >取 消</el-button>
                    <el-button
                        type="primary"
                        size="small"
                        @click="fnConfrimTypeName()"
                    >确 定</el-button>
                </span>
            </el-dialog>
            <!-- /修改分类 -->

            <!-- 代理类目 -->
            <el-dialog
                :visible.sync="dialogVisibleAgent"
                width="400px"
            >
                <div class="el-type-name">
                    <p style="marginRight: 10px;">所属类目:</p>
                    <el-select
                        v-model="agent"
                        placeholder="请选择"
                        size="small"
                    >
                        <el-option
                            v-for="item in agentList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div
                    slot="footer"
                    style="width:100%;display:flex;justify-content: center;"
                >
                    <el-button
                        type="primary"
                        size="small"
                        @click="fnConfrimAgent()"
                    >创 建</el-button>
                </div>
            </el-dialog>

            <!-- 选择学校 -->
            <el-dialog
                title="选择学校"
                width="1048px"
                custom-class="choose-dialog"
                :visible.sync="showChooseSchool"
            >
                <el-cascader
                    v-model="selectedCity"
                    placeholder="请选择城市"
                    :options="cities"
                    :props="props"
                    filterable
                    size="small"
                    style="width: 120px;marginBottom:15px"
                    @change="fnChangeCity"
                />
                <el-input
                    placeholder="请输入搜索内容"
                    v-model.trim="searchKey"
                    size="small"
                    style="width: 380px"
                    @keyup.native.enter="fnSearchSchool()"
                >
                    <el-button
                        slot="append"
                        icon="el-icon-search"
                        @click="fnSearchSchool()"
                    />
                </el-input>
                <div
                    class="el-tag-school"
                    v-if="isSchool"
                >
                    <el-tag
                        :key="tag"
                        v-for="tag in selectedSchools"
                        closable
                        :disable-transitions="false"
                        @close="handleCloseSchool(tag)"
                    >
                        {{ JSON.parse(tag).name }}
                    </el-tag>
                </div>
                <div class="splider" />
                <div class="school-list">
                    <div
                        class="empty"
                        v-if="schoolList.length <= 0"
                    >
                        请切换城市
                    </div>
                    <el-checkbox-group
                        v-model="selectedSchools"
                        size="small"
                        v-else
                    >
                        <el-checkbox-button
                            v-for="(school, schoolIndex) in schoolList"
                            :label="JSON.stringify({
                                id: school.id,
                                name: school.name
                            })"
                            :key="schoolIndex"
                        >{{ school.name }}</el-checkbox-button>
                    </el-checkbox-group>
                </div>
                <div
                    class="el-school-filter"
                >
                    <p style="color:#7e8993;paddingRight:8px">设置学校权限:</p>
                    <el-switch
                        v-model="filter_status"
                        active-color="#13ce66"
                        :active-value="1"
                        :inactive-value="0"
                    />
                </div>
                <el-button
                    type="primary"
                    size="small"
                    class="submit-btn"
                    @click="fnSchooldAuthor()"
                >确定</el-button>
            </el-dialog>
        <!-- 选择学校 -->
        </div>

        <!-- 设置商品组 -->
        <shop-group
            ref="shopGroup"
            @sendData="getData"
        />

        <!-- 查看优惠力度 -->
        <!-- 预览图片 -->
        <img-preview ref="preview"/>
    </div>
</template>

<script>
import shopGroup from '@/components/student/shop-group';
import ImgPreview from "@/components/common/img-preview";
export default {
    components: {
        ImgPreview,
        shopGroup
    },
    data() {
        return {
            groupType: '',//1:商品组跳转 2:商品分类跳转
            loadingData: true,
            agent:'',
            agentList: [],//代理类目数据
            shop_type_status: '', //是否批量设置商品分类 true:批量 false:单独
            is_cate: false,
            autoinc_view_set: 99,
            add_shop_type: '',
            menuList: [
                '推荐到商品组',
                '批量审核通过',
                '批量下架',
                '批量上架',
                '推荐到0元购',
                '添加自动销量',
                '移除自动销量',
                '批量删除商品',
                '推荐到秒杀',
                '设置学校权限',
                '添加自动浏览量',
                '移除自动浏览',
                '编辑商品分类',
                '设置类目代理',
            ],
            goods_no: '', //记录编号
            type_name: '',
            dialogVisibleAgent: false,
            dialogVisibleTypeName: false,
            browse: '',
            browseList: [],
            dialogVisiblBrowse: false,
            browseData: {
                browse_type: 0,
                browse_date: []
            },
            volume: 99,
            volumeList: [{
                value: 99,
                label: '全部'
            },{
                value: 0,
                label: '否'
            },{
                value: 1,
                label: '是'
            }],
            tableDateResh: [],
            dialogVisibleList: false,
            fold_text: '展开',
            isFold: true,
            ifEnter: true,
            labelTagList: [],
            ificationLabelList: [],
            target_no: '',
            isLabel: true,
            restaurantsLabel: [],
            results: '',
            labelList: [],
            label: '',
            restaurants: [],
            searchLabelList: [],
            defaultLabel: [],
            centerDialogVisible: false,
            ruleFormLabel: {
                type: 2,
                label: '',
                tag: ''
            },
            rulesLabel: {
                label: [
                    { required: true, message: '请选择分类,不可以为空', trigger: 'blur' }
                ],
                tag: [
                    { required: true, message: '请填写标签,不可以为空', trigger: 'blur' }
                ]
            },
            mergeDialogVisible: false,
            shopListChoose: [],
            loading: false,
            showAddDialog: false,
            ruleForm: {
                shop_social_type: 1,
                shop_no: '',
                url: '',
                fication: ''
            },
            rules: {
                url: [
                    {required: true, message: '请输入商品链接', trigger: 'blur'}
                ],
                shop_no: [
                    {required: true, message: '请选择店铺', trigger: 'change'}
                ],
                fication: [
                    {required: true, message: '请选择商品分类', trigger: 'change'}
                ],
            },
            authResult: {},
            checkedAll: false,
            checkIndeterminate: false,
            multipleSelection: [],
            goodsTypeList: [
                {
                    value: '1',
                    label: '自营'
                },{
                    value: '2',
                    label: '合作淘客'
                },{
                    value: '3',
                    label: '其他淘客'
                },{
                    value: '4',
                    label: '商圈商品'
                },
            ],
            shosenList: [{
                value: '',
                label: '全部'
            }, {
                value: '1',
                label: '精选'
            }, {
                value: '2',
                label: '非精选'
            },],
            typeList: [],
            typeAllListType: [],
            cateList: [],
            audioList: [
                {
                    value: '',
                    label: '全部'
                },{
                    value: '1',
                    label: '待审核'
                },{
                    value: '2',
                    label: '审核通过'
                },{
                    value: '3',
                    label: '审核不通过'
                }
            ],
            goodsList: [{
                value: '',
                label: '全部'
            },{
                value: '1',
                label: '已上架'
            },{
                value: '-1',
                label: '已下架'
            }],
            tableData: [],
            filterData: {
                selectedType: [],//选中分类
                goods_type: 1,
                audit_status: '',
                cate_no: '',
                cate_type_no: '',
                goodType: [],
                goods_title: '',
                shop_title: '',
                shop_no: '',
                sort_field: '',
                sort_type: '',
                tuan_price_range: '',
                tuan_price_rangeEnd: '',
                origin_price_range: '',
                origin_price_rangeEnd: '',
                coupon_money_range: '',
                coupon_money_rangeEnd: '',
                commission_money_range: '',
                commission_money_rangeEnd: '',
                sale_range: '',
                sale_rangeEnd: '',
                tuan_num: '',
                goods_status: '',
                money_range_start: '',
                money_range_end: '',
                price_range_start: '',
                price_range_end: '',
                cate_no_type: '',
                goods_price_pay_start: '',
                goods_price_pay_end: '',
                set_cate_recommend: '',
                shop_social_type: 99,
                goods_no: '',
                item_id: ''
            },
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 20
            },
            operateNo: '',
            dialogOrderNoVisiable: false,
            dialogReasonVisiable: false,
            orderNoForm: {
                complete_remark: ''
            },
            refuseForm: {
                reason: ''
            },
            showJingangDialog: false,
            checkedJingang: [],
            indexSucess: 0,
            indexError: 0,
            // 学校过滤
            school_filter_status: 99,
            filter_status: 1,
            isSchool: true,
            filterList: [{
                value: '',
                label: '全部'
            },{
                value: 1,
                label: '是'
            },{
                value: 0,
                label: '否'
            }],
            filterAuthList: [{
                value: 99,
                label: '全部'
            },{
                value: 1,
                label: '是'
            },{
                value: 0,
                label: '否'
            }],
            showChooseSchool: false,
            selectedCity: [],
            cities: [],
            searchKey: '',
            // 弹窗当前显示学校集合
            schoolList: [],
            // 当前选中的学校
            selectedSchools: [],
            //所有学校集合
            city_schools: {},
            props: {
                value: 'id',
                label: 'name',
                children: 'children'
            }
        };
    },
    computed: {
        checkAllStatus: {
            get() {
                if(this.multipleSelection.length == 0) {
                    return false;
                }else if(this.multipleSelection.length == this.tableData.length) {
                    return true;
                }
            },
            set() {
                return true;
            }
        },
        typeAllList(){
            return [].concat(this.typeList);
        },
        showCancelJingang(){

            //选中金刚区分类的筛选,则显示取消金刚区按钮
            if(this.filterData.selectedType.length == 2 && this.filterData.selectedType[0] == '*' && !!this.filterData.selectedType[1]){
                return true;
            }
            return false;
        }
    },
    filters: {
        specFilter(val){
            if(!val){
                return '--';
            }
            let str = '';

            for(var i in val.spec_list){
                str += val.spec_list[i].spec_name + ':' + val.spec_list[i].spec_value;
                if(i < val.spec_list.length){
                    str += ',';
                }else{
                    str += ': ';
                }
            }

            if(str){
                str += '佣金' + val.product_commission+'元';
            }
            return str;
        },
        commissionRateFilter(val){
            if(val <= 0){
                return '--';
            }
            return val*1 + '%';
        },
        setGoodsType (val) {
            if (val == 1) {
                return '自营';
            } else if (val == 2) {
                return '合作淘客';
            } else if (val == 3) {
                return '普通淘客';
            } else if (val == 4) {
                return '商圈商品';
            } else if (val == 10) {
                return '二手商品';
            } else if (val == 11) {
                return '京东商品';
            } else if (val == 12) {
                return '拼多多商品';
            }
        },
        socialFilter(val) {
            switch (val) {
                case 1:
                    return '淘宝';
                case 2:
                    return '京东';
                case 3:
                    return '拼多多';
                default:
                    return '--';
            }
        },
    },
    watch: {
        showChooseSchool (val) {
            this.fnGetSchoolList();
        },
        showAddDialog (val) {
            if (!val) {
                this.ruleForm = {
                    shop_social_type: 1,
                    shop_no: '',
                    url: '',
                    fication: ''
                };
            }
        },
        centerDialogVisible (val) {
            if (!val) {
                this.ruleFormLabel = {
                    type: 1,
                    label: '',
                    tag: ''
                };
            }
        },
        mergeDialogVisible (val) {
            if (!val) {
                this.labelList = [];
                this.labelTagList = [];
                this.label = '';
            }
        },
        dialogVisiblBrowse (val) {
            if (!val) {
                this.browse = '';
            }
        },
        dialogVisibleAgent (val) {
            if(!val) {
                this.agent = '';
            }
        }
    },
    mounted () {
        this.authResult = this.$route.meta.authResult;
        this.getUrl();
        this.init();

        setTimeout(()=>{
            this.fnGetSchoolList();
            this.fnGetGoodsType();
            this.fnGetCateType();
            this.fnGetAgentList();
        },1000);
    },
    methods: {

        /**
         * 路由跳转
         * @param routeName
         * @param query
         */
        handleRoute(routeName, query) {
            this.$router.push({
                name: routeName,
                query
            });
        },

        /**
         * 学校权限
         */
        fnChangeCity() {
            if (this.selectedCity.length >= 2) {
                this.schoolList = this.city_schools['city_' + this.selectedCity[1]];
                this.searchKey = '';
            } else {
                this.schoolList = [];
                this.searchKey = '';
            }
        },
        fnSearchSchool() {
            if (this.selectedCity.length >= 2) {
                this.schoolList = this.city_schools['city_' + this.selectedCity[1]].filter(item => {
                    if (!this.searchKey) {
                        return true;
                    }
                    return item.name.indexOf(this.searchKey) > -1;
                });
            } else {
                this.schoolList = [];
            }
        },
        fnGetSchoolList() {
            this.$post('/student/local_info%5Cschool_tree', {
            }, resp => {
                if (resp.code == 1) {
                    // 将学校与省市剥离,方便显示以及遍历
                    let tree = resp.data.tree;
                    let cityTmp = [];
                    let schoolTmp = {};

                    tree.forEach(item => {
                        let provinceTmp = {
                            id: item.id,
                            name: item.name,
                            children: []
                        };

                        if (item.children) {
                            item.children.forEach((city) => {
                                provinceTmp.children.push({
                                    id: city.id,
                                    name: city.name
                                });
                                schoolTmp['city_' + city.id] = city.children;
                            });
                        }
                        cityTmp.push(provinceTmp);
                    });

                    this.cities = cityTmp;
                    this.city_schools = schoolTmp;
                    this.selectedCity = [12, 88];
                    this.fnChangeCity();
                }
            });
        },

        /**
         * 批量设置学校权限
         */
        fnSetSchool () {
            this.isSchool = false;
            this.selectedSchools = [];
            this.showChooseSchool = !this.showChooseSchool;
        },

        /**
         * 移除学校
         */
        handleCloseSchool (tag) {
            this.selectedSchools.splice(this.selectedSchools.indexOf(tag), 1);
        },

        /**
         * 单个设置学校权限
         */
        fnSetAuthor (row) {
            this.goods_no = row.goods_no;
            this.isSchool = true;
            this.$post('/student/shop_goods%5Cget_school_filter',{
                goods_no: row.goods_no,
            },resp => {
                if (resp.code == 1) {
                    let school = [];

                    this.showChooseSchool = !this.showChooseSchool;
                    setTimeout(()=> {
                        this.filter_status = resp.data.school_filter_status;
                        resp.data.school_filter_school_ids.map(item => {
                            this.schoolList.map(option => {
                                if (item == option.id) {
                                    school.push(JSON.stringify({
                                        id: option.id,
                                        name: option.name
                                    }));
                                }
                            });
                        });
                        this.selectedSchools = school;
                    },100);

                } else {
                    this.$message({
                        type: 'waring',
                        message: resp.msg,
                        center: true
                    });
                }
            });
        },

        /**
         * 设置商品精选
         */
        fnSetCateRecommend (row, param) {
            this.$post('/student/shop_goods_cate%5Cset_goods_recommend',{
                cate_no: this.filterData.cate_no_type,
                goods_no: row.goods_no,
                type: param == 1 ? 1 : 2
            }, resp => {
                if (resp.code == 1) {

                    this.$set(row,'cate_recommend', param);
                    if(param == 1) {
                        this.$message({
                            type: 'success',
                            message: '已加入精选',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'success',
                            message: '已取消精选',
                            center: true
                        });
                    }
                } else {
                    this.$message({
                        type: 'waring',
                        message: resp.msg,
                        center: true
                    });
                }
            });
        },

        /**
         * 获取代理类目数据列表
         */
        fnGetAgentList () {
            this.$post('/student/shop_goods_agent_cate%5Cget_list_select', {}, resp => {
                if (resp.code == 1) {
                    if(resp.data.list.length > 0) {
                        resp.data.list.map(item => {
                            this.agentList.push({
                                value: item.cate_no,
                                label: item.cate_name
                            });
                        });
                    }
                }
            });
        },

        /**
         * 单独设置商品代理类目
         */
        fnSetAgent (row) {
            this.goods_no = row.goods_no;
            this.agent = row.agent_cate_no;
            this.dialogVisibleAgent = !this.dialogVisibleAgent;
        },

        /**
         * 设置商品代理类目
         */
        fnConfrimAgent () {
            console.log(this.agent, this.multipleSelection, '11');
            let goods_nos = [];

            if(this.multipleSelection.length == 0) {
                goods_nos.push(this.goods_no);
            } else {
                this.multipleSelection.map(item => {
                    goods_nos.push(item.goods_no);
                });
            }

            setTimeout(()=>{
                this.$post('/student/shop_goods%5Cset_agent_cate_no_batch', {
                    goods_nos: goods_nos.join(),
                    agent_cate_no: this.agent
                }, resp => {
                    if (resp.code == 1) {
                        this.dialogVisibleAgent = !this.dialogVisibleAgent;
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '设置成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            },200);

        },

        /**
         * 确定设置过滤学校
         */
        fnSchooldAuthor () {
            let school_filter_school_ids = [];

            if (Object.keys(this.selectedSchools).length >= 1 ) {
                this.selectedSchools.map(item=>{
                    school_filter_school_ids.push(
                        JSON.parse(item).id
                    );
                });
            }

            if (this.isSchool) {
                this.$post('/student/shop_goods%5Cset_school_filter',{
                    goods_no: this.goods_no,
                    school_filter_status: this.filter_status,
                    school_filter_school_ids: school_filter_school_ids.length > 0 ? school_filter_school_ids.join() : ''
                },resp => {
                    if (resp.code == 1) {
                        this.getTableData();
                        this.showChooseSchool = !this.showChooseSchool;
                        this.$message({
                            type: 'success',
                            message: '设置成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            } else {
                this.multipleSelection.map(item => {
                    this.$post('/student/shop_goods%5Cset_school_filter',{
                        goods_no: item.goods_no,
                        school_filter_status: this.filter_status,
                        school_filter_school_ids: school_filter_school_ids.length > 0 ? school_filter_school_ids.join() : ''
                    },resp => {
                        if (resp.code == 1) {
                            this.getTableData();
                        } else {
                            this.indexError ++;

                        }
                    });
                });

                setTimeout(()=>{
                    if (this.indexError > 0) {
                        this.$message({
                            type: 'waring',
                            message: `设置失败${this.indexError}个`,
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'success',
                            message: '设置成功',
                            center: true
                        });
                    }
                    this.indexError = 0;
                    this.showChooseSchool = !this.showChooseSchool;
                },500);
            }
        },

        /**
         * 获取url参数
         */
        getUrl () {
            let query = this.$route.query;

            if (query.shop_title !== undefined ) {
                this.filterData.shop_title = query.shop_title;
            } else if (query.page !== undefined || query.filterData !== undefined) {
                this.page.now_page = Number(query.page);
                this.filterData = JSON.parse(query.filterData);
            }
        },

        /**
         * 自定义表格标题hover提示
         */
        renderHeader(h){
            return h('span', {}, [
                h('span', {style: 'font-weight: bold'}, '平台售价'),
                h('el-popover', { props: { placement: 'top-start', width: '200', trigger: 'hover', content: '平台售价为当前该商品在各平台上的在售价格' }}, [
                    h('i', { slot: 'reference', class:'el-icon-question'}, '')
                ])
            ]);
        },
        renderHeaderPay(h){
            return h('span', {}, [
                h('span', {}, '学生价'),
                h('el-popover', { props: { placement: 'top-start', width: '200', trigger: 'hover', content: '学生价为该商品抵消优惠券后的价格，即APP中显示的学生价' }}, [
                    h('i', { slot: 'reference', class:'el-icon-question'}, '')
                ])
            ]);
        },

        /**
         * 折叠heade
         */
        fnFold () {
            this.isFold = !this.isFold;
            if (this.isFold) {
                this.fold_text = '展开';
            } else {
                this.fold_text = '折叠';
            }
        },

        /**
         * 修改分类
         */
        fnSetTypename (row) {
            this.goods_no = row.goods_no;
            this.shop_type_status = false;

            this.$post('/student/shop_goods%5Cget',{
                goods_no: this.goods_no
            },resp=>{
                if (resp.code == 1) {
                    this.type_name = [
                        resp.data.parent_type_no,
                        resp.data.type_no
                    ];
                    this.dialogVisibleTypeName = !this.dialogVisibleTypeName;
                } else {
                    this.$message({
                        type: 'waring',
                        message: resp.msg,
                        center: true
                    });
                }
            });
        },

        /**
         * 确认修改分类
         */
        fnConfrimTypeName () {
            if (this.type_name == '') {
                this.$message({
                    type: 'waring',
                    message: '请选择分类',
                    center: true
                });
                return;
            }

            if(!this.shop_type_status) {
                this.$post('/student/shop_goods%5Cmodify',{
                    goods_no: this.goods_no,
                    type_no: this.type_name[this.type_name.length - 1]
                },resp=> {
                    if (resp.code == 1) {
                        this.getTableData();
                        this.dialogVisibleTypeName = !this.dialogVisibleTypeName;
                        this.$message({
                            type: 'success',
                            message: '修改成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            } else {
                let goods_no = [];

                this.multipleSelection.map(item=>{
                    goods_no.push(item.goods_no);
                });

                setTimeout(()=>{
                    if(goods_no.length > 0) {
                        this.$post('/student/shop_goods%5Cset_type_no_batch', {
                            goods_nos: goods_no.join(),
                            type_no: this.type_name[this.type_name.length - 1]
                        }, resp => {
                            if (resp.code == 1) {
                                this.getTableData();
                                this.dialogVisibleTypeName = !this.dialogVisibleTypeName;
                                this.$message({
                                    type: 'success',
                                    message: '修改成功',
                                    center: true
                                });
                            } else {
                                this.$message({
                                    type: 'waring',
                                    message: resp.msg,
                                    center: true
                                });
                            }
                        });
                    }
                },100);

            }

        },

        /**
         * 推荐到0元购
         */
        fnRecommentZeon () {
            let goods_no = [];
            let status = false;

            this.multipleSelection.map(item=>{
                goods_no.push(item.goods_no);
            });
            this.fnRecommentShop(goods_no);
        },

        fnRecommentShop (goods_no) {
            this.$post('/student/shop_free%5Cjoin',{
                goods_no_json: JSON.stringify(goods_no)
            },resp=>{
                this.tableDateResh = resp.data.msg_list;
                this.dialogVisibleList = !this.dialogVisibleList;
            });
        },

        /**
         * 获取商品销量套餐
         */
        fnGetAutoinc (param) {
            this.browseList = [];
            if (param == 1) {
                this.$post('/student/shop_goods_sale_autoinc%5Cget_list', {
                }, resp => {
                    if (resp.code == 1) {
                        this.browseList = resp.data.list;
                    }
                });
            } else {
                this.$post('/student/shop_goods_view_autoinc%5Cget_list', {
                }, resp => {
                    if (resp.code == 1) {
                        this.browseList = resp.data.list;
                    }
                });
            }
        },

        /**
         * 初始化添加自动浏览日期数据
         */
        browsePickerOptions () {
            return {
                shortcuts: [{
                    text: '最近一周',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();

                        start.setTime(start.getTime() + 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', [end, start]);
                    }
                }, {
                    text: '最近一个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();

                        start.setTime(start.getTime() + 3600 * 1000 * 24 * 30);
                        picker.$emit('pick', [end, start]);
                    }
                }, {
                    text: '最近三个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();

                        start.setTime(start.getTime() + 3600 * 1000 * 24 * 90);
                        picker.$emit('pick', [end, start]);
                    }
                }]
            };
        },

        /**
         * 1:添加自动销量 2:自动浏览量
         */
        fnAddVolum (param) {
            this.browsePickerOptions();
            if (param == 1) {
                this.fnGetAutoinc(1);
                let list = this.multipleSelection;

                this.add_shop_type = 1;
                for(let i=0; i<list.length;i++) {
                    if (list[i].goods_type == 2 || list[i].goods_type == 3) {
                        this.$message({
                            type: 'waring',
                            message: '销量自增长,只对自营商品和商圈商品有效,请重新选择商品',
                            center: true
                        });
                        return;
                    }
                }
            } else {
                this.add_shop_type = 2;
                this.fnGetAutoinc(2);
            }
            this.browseData.browse_date = [];
            this.browseData.browse_type = 0;
            this.dialogVisiblBrowse = !this.dialogVisiblBrowse;
        },

        /**
         * 移除自动销量
         */
        fnRemoveVolum (param) {
            let list = this.multipleSelection;

            if (param == 1) {
                for(let i=0; i<list.length;i++) {
                    if (list[i].goods_type == 2 || list[i].goods_type == 3) {
                        this.$message({
                            type: 'waring',
                            message: '销量自增长,只对自营商品和商圈商品有效,请重新选择商品',
                            center: true
                        });
                        return;
                    }
                }
            }

            this.$confirm('此操作将移除所选中商品增长量, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                if (param == 1) {
                    this.multipleSelection.map(item=>{
                        if (item.autoinc_sale.autoinc_no !== '') {
                            this.$post('/student/shop_goods_sale_autoinc%5Cunset_autoinc',{
                                goods_no: item.goods_no
                            },resp=>{
                                if (resp.code == 1) {
                                    //
                                } else {
                                    this.$message({
                                        type: 'waring',
                                        message: resp.msg,
                                        center: true
                                    });
                                }
                            });
                        }
                    });
                } else {
                    this.multipleSelection.map(item=>{
                        if (item.autoinc_view.autoinc_no !== '') {
                            this.$post('/student/shop_goods_view_autoinc%5Cunset_autoinc',{
                                goods_no: item.goods_no
                            },resp=>{
                                if (resp.code == 1) {
                                    //
                                } else {
                                    this.$message({
                                        type: 'waring',
                                        message: resp.msg,
                                        center: true
                                    });
                                }
                            });
                        }
                    });
                }

                this.getTableData();
                this.$message({
                    type: 'success',
                    message: '移除成功',
                    center: true
                });
            });
        },

        /**
         * 批量删除商品
         */
        fnRemoveShop () {
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let goods_json = [];

                this.multipleSelection.map(item=>{
                    goods_json.push(item.goods_no);
                });

                this.$post('/student/shop_goods%5Cdelete_batch',{
                    goods_no_json: JSON.stringify(goods_json)
                },resp=>{
                    if (resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '移除成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            });
        },

        /**
         * 推荐到秒杀
         */
        fnRecommonMs () {
            let list = this.multipleSelection;

            for(let i=0; i<list.length;i++) {
                if (list[i].goods_type == 1 || list[i].goods_type == 4) {
                    this.$message({
                        type: 'waring',
                        message: '只可推荐淘客类商品',
                        center: true
                    });
                    return;
                }
            }

            let str = [];

            this.$confirm('此操作将批量添加到秒杀, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.multipleSelection.map(item=> {
                    str.push(item.goods_no);
                });
                this.$post('/student/shop_goods_flash_sale%5Cadd_tao_item',{
                    goods_nos: str.join()
                },resp=>{
                    if (resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '添加成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            });
        },

        /**
         * 确定设置商品销量
         */
        fnConfirmBrowse () {
            this.browsePickerOptions();
            if (this.browse == '') {
                this.$message({
                    type: 'waring',
                    message: '不可以为空,请选择自动增长量',
                    center: true
                });
                return;
            }

            if (this.add_shop_type == 1) {
                this.multipleSelection.map(item=> {
                    this.$post('/student/shop_goods_sale_autoinc%5Cset_autoinc',{
                        autoinc_no: this.browse,
                        goods_no: item.goods_no
                    },resp=>{
                        if (resp.code == 1) {
                            //
                        } else {
                            this.$message({
                                type: 'waring',
                                message: resp.msg,
                                center: true
                            });
                        }
                    });
                });
            } else if (this.add_shop_type == 2) {
                if(this.browseData.browse_type == 1) {
                    if(this.browseData.browse_date === null) {
                        this.$message({
                            type: 'waring',
                            message: '请选择日期范围,不可以为空',
                            center: true
                        });
                        return false;
                    }
                    if(this.browseData.browse_date.length == 0) {
                        this.$message({
                            type: 'waring',
                            message: '请选择日期范围,不可以为空',
                            center: true
                        });
                        return false;
                    }
                }

                this.multipleSelection.map(item=> {
                    this.$post('/student/shop_goods_view_autoinc%5Cset_autoinc',{
                        autoinc_no: this.browse,
                        goods_no: item.goods_no,
                        valid_start_time: this.browseData.browse_type ? parseInt((new Date(this.browseData.browse_date[0]).getTime() / 1000)) : 0,
                        valid_end_time: this.browseData.browse_type ? parseInt((new Date(this.browseData.browse_date[1]).getTime() / 1000)) : 0
                    },resp=>{
                        if (resp.code == 1) {
                            //
                        } else {
                            this.$message({
                                type: 'waring',
                                message: resp.msg,
                                center: true
                            });
                        }
                    });
                });
            } else {
                return;
            }
            this.dialogVisiblBrowse = !this.dialogVisiblBrowse;
            this.getTableData();
            this.$message({
                type: 'success',
                message: '设置成功',
                center: true
            });
        },

        /**
         * 打标签
         */
        fnLabel (row) {
            this.target_no = row.goods_no;
            this.mergeDialogVisible = !this.mergeDialogVisible;
            this.restaurants = [];
            this.fnLabelList();
            this.fnGetDefaultLabel('');
            this.fnGetLabelList();
        },

        /**
         * 获取标签列表/筛选
         */
        fnLabelList () {
            this.$post('/student/tag%5Cget_simple_list', {
                target_type: 2,
                keyword: '',
                group_no: ''
            }, resp=> {
                if (resp.code == 1) {
                    if (resp.data.list.length > 0) {
                        this.restaurants = resp.data.list;
                    }
                }
            });
        },

        /**
         * 获取被打标签
         */
        fnGetLabelList () {
            this.$post('/student/tag%5Cget_item_tag_list', {
                target_type: 2,
                target_no: this.target_no
            }, resp=> {
                if (resp.code == 1) {
                    if (resp.data.list.length > 0) {
                        resp.data.list.map(item=>{
                            this.labelList.push(item.name);
                            this.labelTagList.push({
                                name: item.name,
                                tag_no: item.tag_no
                            });
                        });
                    }
                }
            });
        },

        /**
         * 获取默认推荐标签/换一批
         */
        fnGetDefaultLabel (group_no) {
            this.$post('/student/tag%5Cget_simple_group_tag_list', {
                target_type: 2,
                group_tag_count: 20,
                group_no: group_no
            }, resp => {
                if (resp.code == 1 && resp.data.list.length > 0) {
                    this.isLabel = false;
                    if (group_no == '') { //默认
                        this.defaultLabel = resp.data.list;
                    } else if (group_no !== '') { //刷新数据用
                        this.defaultLabel.map((item,index)=>{
                            if(item.group_no == group_no) {
                                this.defaultLabel.splice(index, 1, resp.data.list[0]);
                            }
                        });
                    }
                }
            });
        },

        /**
         * 换一批
         */
        fnlabelRefresh (item) {
            this.fnGetDefaultLabel(item);
        },
        fnClearLabel () {
            this.label = '';
        },

        //选择联想数据，打标签
        handleLabelSelect(item) {
            if (typeof(item) == 'object') {
                this.labelTagList.push(this.label);
                this.label = this.label.name;
                this.labelList.push(this.label);
                setTimeout(()=>{
                    this.$refs.labelClear.blur();
                },30);
            } else {
                this.label = item;
            }
        },

        //回车创建新标签
        handleLabelEnter (e) {

            if (this.label.length > 0) {
                this.ruleFormLabel.tag = this.label;
                this.centerDialogVisible = !this.centerDialogVisible;
                this.fnSelectType('shop');
            } else {
                return;
            }
        },

        /**
         * 确定添加商品标签
         */
        submitFormMerge() {
            let str = '';

            if (this.labelTagList.length > 0) {
                this.labelTagList.map(item=>{
                    str += item.tag_no + ',';
                });
                this.$post('/student/tag%5Cclear_and_set_item_tag',{
                    target_type: 2,
                    tag_nos: str,
                    target_no: this.target_no
                },resp=> {
                    if(resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '添加成功'
                        });
                        this.mergeDialogVisible = !this.mergeDialogVisible;
                    } else if (resp.code == 0) {
                        this.$message({
                            type: 'waring',
                            message: resp.msg
                        });
                    }
                });
            } else {
                this.$post('/student/tag%5Cclear_and_set_item_tag',{
                    target_type: 2,
                    tag_nos: '',
                    target_no: this.target_no
                },resp=> {
                    if(resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '添加成功'
                        });
                        this.mergeDialogVisible = !this.mergeDialogVisible;
                    } else if (resp.code == 0) {
                        this.$message({
                            type: 'waring',
                            message: resp.msg
                        });
                    }
                });
            }
        },
        fnBeforeColse (done) {
            this.fnLabelCancel();
        },

        /**
        * 取消打标签
         */
        fnLabelCancel () {
            this.$confirm('是否取消?', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.mergeDialogVisible = !this.mergeDialogVisible;
            });
        },

        /**
         * 获取分组数据
         */
        fnSearchLabel () {
            this.$post('/student/tag_group%5Cget_simple_list', {
                target_type: this.ruleFormLabel.type,
                keyword: this.ruleFormLabel.label
            }, resp=> {
                if (resp.code == 1) {
                    if (resp.data.list.length > 0) {
                        this.ificationLabelList = resp.data.list;
                    }
                } else if (resp.code == 0) {
                    this.$message({
                        type: 'waring',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 选择类型
         */
        fnSelectType (type) {
            if (type == 'shop') {
                this.ruleFormLabel.type = 2;
                this.restaurantsLabel = [];
                this.fnSearchLabel();
            }
        },
        handleSelectLabel(item) {
            this.ruleFormLabel.label = item;
        },

        /**
         * 弹窗保存新增标签
         */
        submitFormLabel(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.$post('/student/tag%5Cadd', {
                        target_type: 2,
                        group_no: this.ruleFormLabel.label,
                        name: this.ruleFormLabel.tag
                    }, resp => {
                        if (resp.code == 1) {
                            this.$message({
                                type: 'success',
                                message: '添加成功'
                            });

                            let label = {
                                name: this.ruleFormLabel.tag,
                                tag_no: resp.data['tag_no']
                            };

                            this.fnGetDefaultLabel('');
                            this.labelTagList.push(label);
                            this.label = this.ruleFormLabel.tag;
                            this.labelList.push(label.name);
                            this.centerDialogVisible = !this.centerDialogVisible;
                        } else if (resp.code == 0) {
                            this.$message({
                                type: 'waring',
                                message: resp.msg
                            });
                        }
                    });
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },

        /**
         * 删除标签
         */
        handleClose (tag,index) {
            this.labelList.splice(this.labelList.indexOf(tag), 1);
            this.labelTagList.splice(this.labelList.indexOf(tag), 1);
        },

        /**
         * 点击添加标签
         */
        fnGetLabel (tag) {
            this.labelList.push(tag.name);
            this.labelTagList.push(tag);
        },

        /**
       * 初始化
       */
        init() {
            this.$store.commit('SET_HEADER', [
                {
                    title: "APP后台",
                },
                {
                    title: "商城",
                },
                {
                    title: '商品列表'
                }
            ]);
            let searchType = [];

            if(this.$route.query.type_no){
                searchType.push(this.$route.query.type_no);
                if(this.$route.query.sub_type_no){
                    this.filterData.cate_no_type = this.$route.query.sub_type_no;
                    searchType.push(this.$route.query.sub_type_no);
                }
                if(this.$route.query.is_cate) {
                    this.is_cate = this.$route.query.is_cate;
                }
                if(this.$route.query.cate_recommend) {
                    this.$set(this.filterData, 'set_cate_recommend', Number(this.$route.query.cate_recommend));
                }
                // if(this.$route.query.has_type) {
                //     this.ification = 0;
                // }
            }

            if(this.$route.query.goods_title || this.$route.query.shop_title){
                this.filterData.goods_title = this.$route.query.goods_title;
                this.filterData.shop_title = this.$route.query.shop_title;
            }

            if(this.$route.query.shop_no) {
                this.filterData.shop_no = this.$route.query.shop_no;
            }
            if(this.$route.query.goods_no) {
                this.filterData.goods_no = this.$route.query.goods_no;
            }

            //商城数据大盘排名前100匹配
            if(this.$route.query.goods_title && this.$route.query.goods_type) {
                this.filterData.goods_title = this.$route.query.goods_title;
                if(this.$route.query.goods_type == 'e_ticket'){
                    this.filterData.goods_type = 4;
                } else if (this.$route.query.goods_type == 'self') {
                    this.filterData.goods_type = 1;
                } else if (this.$route.query.goods_type == 'tao') {
                    this.filterData.goods_type = 3;
                }
            }

            //商品组/分类管理
            if(this.$route.query.sub_type_no && this.$route.query.cate_type_no) {
                this.filterData.cate_no_type = this.$route.query.sub_type_no;
                this.filterData.cate_type_no = this.$route.query.cate_type_no;
            }

            //区分是否从商品组跳转
            if(this.$route.query.sub_type_no && this.$route.query.is_group) {
                this.groupType = Number(this.$route.query.is_group);

                if(this.groupType == 1) {
                    this.menuList.unshift('移出商品组');
                }else if(this.groupType == 2) {
                    this.menuList.unshift('移出此分类');
                }
            }

            if(this.$route.query.is_cate) {
                this.is_cate = this.$route.query.is_cate;
            }

            this.filterData.is_chosen = this.$route.query.is_chosen ? (this.$route.query.is_chosen+'') : '';

            this.filterData.selectedType = searchType;
            this.getTableData();
        },

        /** 商品二级分类 */
        fnGetGoodsType(){
            this.$post('/student/shop_goods_type%5Cget_list_linkage', {}, resp => {
                if(resp.code == 1){
                    this.typeList = resp.data.list;
                }
            });
            this.$post('/student/shop_goods_cate%5Cget_list_select',{},resp=>{
                if (resp.code == 1) {
                    this.typeAllListType = resp.data.list;
                }
            });
        },

        /** 精选分类 */
        fnGetCateType(){
            this.$post('/student/shop_goods_cate%5Cget_list_select', {}, resp => {
                if(resp.code == 1){
                    let cates = resp.data.list.map(val => {
                        return {
                            no: val.cate_no,
                            title: val.cate_name
                        };
                    });

                    this.cateList = cates;
                }
            });
        },

        /**
       * 获取表格数据
       */
        getTableData(page) {
            this.checkedAll = false;
            this.loadingData = true;

            // 异常处理
            let querys = this.$route.query;

            if(querys.type_no && querys.sub_type_no) {
                this.filterData.cate_no_type = '';
            }

            let query = {
                type_no: '',
                sub_type_no: '',
                goods_type: this.filterData.goods_type,
                goods_status: this.filterData.goods_status,
                audit_status: this.filterData.audit_status,
                goods_title: this.filterData.goods_title,
                shop_title:this.filterData.shop_title,
                page_id: page || this.page.now_page,
                page_size: this.page.page_size,
                sort_field: this.filterData.sort_field,
                sort_type: this.filterData.sort_type,
                is_chosen: this.filterData.is_chosen,
                // tuan_price_range: this.filterData.tuan_price_range + '-' + this.filterData.tuan_price_rangeEnd,
                // origin_price_range: this.filterData.origin_price_range + '-' + this.filterData.origin_price_rangeEnd,
                // goods_price_range: this.filterData.price_range_start + '-' + this.filterData.price_range_end,
                rights_money_range: this.filterData.money_range_start + '-' + this.filterData.money_range_end,
                // coupon_money_range: this.filterData.coupon_money_range + '-' + this.filterData.coupon_money_rangeEnd,
                commission_money_range: this.filterData.commission_money_range + '-' + this.filterData.commission_money_rangeEnd,
                // sale_range: this.filterData.sale_range + '-' + this.filterData.sale_rangeEnd,
                // tuan_num: this.filterData.tuan_num,
                cate_no: this.filterData.cate_no_type,
                cate_recommend: this.filterData.set_cate_recommend,
                cate_type_no: this.filterData.cate_type_no,
                // goods_price_buy_range: this.filterData.goods_price_pay_start + '-' + this.filterData.goods_price_pay_end,
                autoinc_sale_set: this.volume,
                school_filter_status: this.school_filter_status,
                autoinc_view_set: this.autoinc_view_set,
                shop_no: this.filterData.shop_no,
                shop_social_type: this.filterData.shop_social_type,
                goods_no: this.filterData.goods_no,
                item_id: this.filterData.item_id,
            };

            if (this.filterData.selectedType && this.filterData.selectedType.length >= 1) {
                if(this.filterData.selectedType[0] == '*'){
                    query.cate_no = '*';
                }else{
                    query.type_no = this.filterData.selectedType[0];
                }
            }

            if (this.filterData.selectedType && this.filterData.selectedType.length == 2) {
                if(this.filterData.selectedType[0] == '*'){
                    query.cate_no = this.filterData.selectedType[1];
                }else{
                    query.type_no = this.filterData.selectedType[0];
                    query.sub_type_no = this.filterData.selectedType[1];
                }
            }

            this.$post('/student/shop_goods%5Cget_list', query, resp => {
                if (resp.code == 1) {
                    this.tableData = resp.data.list;
                    this.page.now_page = resp.data.page.now_page;
                    this.page.total_count = resp.data.page.total_count;
                    this.page.page_size = resp.data.page.page_size;
                    if (resp.data.page.total_page > 0 && resp.data.page.total_page < resp.data.page.now_page) {
                        this.getTableData(resp.data.page.total_page);
                    }
                }
                this.loadingData = false;
            });

            this.$nextTick(()=>{
                this.$refs.goodsTable.doLayout();
            });
        },
        fnSelect(selection) {
            if(selection.length == this.tableData.length) {
                this.checkedAll = true;
            }else{
                this.checkedAll = false;
            }

            // 改变全选checkbox 的显示状态
            if(selection.length > 0 && selection.length < this.tableData.length) {
                this.checkIndeterminate = true;
            }else{
                this.checkIndeterminate = false;
            }
        },
        fnSelectAllTop(selection) {
            if(selection.length > 0) {
                this.checkedAll = true;
            }else{
                this.checkedAll = false;
            }

            // 改变全选checkbox 的显示状态
            if(selection.length > 0 && selection.length < this.tableData.length) {
                this.checkIndeterminate = true;
            }else{
                this.checkIndeterminate = false;
            }
        },
        fnChangeChecked() {
            if(this.checkedAll){
                this.toggleSelection(1);
            }else{
                this.toggleSelection();
            }
        },
        toggleSelection(rows) {
            if (rows) {
                this.$refs.goodsTable.toggleAllSelection();
            } else {
                this.$refs.goodsTable.clearSelection();
            }
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },

        /**
         * 批量操作
         */
        handleCommand (command) {
            if (this.multipleSelection.length == 0) {
                this.$message({
                    type: 'waring',
                    message: '请先选择商品',
                    center: true
                });
                return;
            }

            switch (command) {
                case '推荐到商品组':
                    this.fnShowPushDialog();
                    break;
                case '批量审核通过':
                    this.fnAudiSuccess();
                    break;
                case '移出商品组':
                    if(this.groupType) {//当从商品组和商品分类进入有此选项
                        this.fnDeleteGroup();
                    }
                    break;
                case '移出此分类':
                    if(this.groupType) {//当从商品组和商品分类进入有此选项
                        this.fnDeleteGroup();
                    }
                    break;
                case '批量下架':
                    this.fnShowPushUpper('-1');
                    break;
                case '批量上架':
                    this.fnShowPushUpper('1');
                    break;
                case '推荐到0元购':
                    this.fnRecommentZeon();
                    break;
                case '添加自动销量':
                    this.fnAddVolum(1);
                    break;
                case '移除自动销量':
                    this.fnRemoveVolum(1);
                    break;
                case '批量删除商品':
                    this.fnRemoveShop();
                    break;
                case '推荐到秒杀':
                    this.fnRecommonMs();
                    break;
                case '设置学校权限':
                    this.fnSetSchool();
                    break;
                case '添加自动浏览量':
                    this.fnAddVolum(2);
                    break;
                case '移除自动浏览':
                    this.fnRemoveVolum(2);
                    break;
                case '编辑商品分类':
                    this.type_name = '';
                    this.shop_type_status = true;
                    this.dialogVisibleTypeName = !this.dialogVisibleTypeName;
                    break;
                case '设置类目代理':
                    this.dialogVisibleAgent = !this.dialogVisibleAgent;
                    break;
                default:
                    break;
            }
        },

        /**
         * 筛选精选商品
         */
        fnSetCate () {
            if(this.filterData.cate_no_type == '' || this.filterData.cate_no_type == null) {
                this.$message({
                    type: 'waring',
                    message: '请先选择商品组,商品组不为空时生效'
                });
                return;
            }
            this.getTableData(1);
        },

        /**
       * 清空筛选数据
       */
        handleResetFilter() {
            this.filterData = {
                title: '',
                type: '0',
                money_type: '0',
                status: '0',
                start_time: '',
                end_time: '',
            };

            this.getTableData(1);
        },

        fnClearFidlds(name) {
            // this.$refs[name].resetFields();
        },

        /**
       * 列表渲染辅助函数：列表项为空处理
       */
        emptyFormatter(row, column, val) {
            if (!val) {
                return '--';
            }
            return val;
        },

        /**
         * 排序修改
         */
        fnEditSort(item, type) {
            this.$prompt('修改', '', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPlaceholder: '请输入数字',
                inputErrorMessage: '请输入正整数',
                inputValue: item.course_sort_global,
                closeOnClickModal: false,
            }).then(({ value }) => {
                this.$post('/student/shop_goods%5Cmodify', {
                    goods_no: item.goods_no,
                    [type] : value
                }, resp => {
                    if (resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '修改成功'
                        });
                        this.$set(item, type, value);
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '修改失败'
                        });
                    }
                });
            });
        },

        /**
         * 商品组分类
         */
        fnEditSortCate (item, type) {
            this.$prompt('修改', '', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPlaceholder: '请输入数字',
                inputErrorMessage: '请输入正整数',
                inputValue: item.course_sort_global,
                closeOnClickModal: false,
            }).then(({ value }) => {
                this.$post('/student/shop_goods_cate_type%5Cset_goods_sort', {
                    goods_no: item.goods_no,
                    cate_type_no: this.$route.query.cate_type_no,
                    sort: value
                }, resp => {
                    if (resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '修改成功'
                        });
                        this.$set(item, type, value);
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '修改失败'
                        });
                    }
                });
            });
        },

        /**
         * 上架/下架
         */
        fnSetStatus (row) {
            this.$post('/student/shop_goods%5Cset_status',{
                goods_no: row.goods_no,
                status: row.goods_status == 1 ? 1 : -1
            },resp => {
                if (resp.code == 1) {
                    this.$message({
                        type: 'success',
                        message: '设置成功'
                    });
                } else if (resp.code == 0) {
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 设置精选状态
         */
        fnSetChoose (row) {

            const status = row.is_chosen == 1 ? 0 : 1;

            this.$post('/student/shop_goods%5Cmodify',{
                goods_no: row.goods_no,
                is_chosen: status
            }, resp => {
                if (resp.code == 1) {
                    this.$set(row, 'is_chosen', status);
                    this.$message({
                        type: 'success',
                        message: '设置成功'
                    });
                } else if (resp.code == 0) {
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 过滤
         */
        typeFormatter(row, column, val) {
            if (val == 1) {
                return '自营';
            } else if (val == 2) {
                return '合作淘客';
            } else if(val == 3) {
                return '其它淘客';
            }else {
                return '--';
            }
        },

        /**
         * 删除商品
         */
        fnDeleteGoods(item){
            this.$confirm('确认删除当前商品?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/shop_goods%5Cdelete', {
                    goods_no: item.goods_no
                }, resp => {
                    if (resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '删除成功'
                        });
                        this.getTableData();
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '删除失败'
                        });
                    }
                });
            });
        },

        /**
         * 排序
         */
        handleSortChanged(data) {

            let sortTypeMap = {
                ascending: 'asc',
                descending: 'desc'
            };

            let sortFieldMap = {
                "goods_sale": 'sale',
                "goods_sale_base": 'sale_base',
                "goods_sort": 'sort',
                "tuan_num": "tuan_num",
                "tuan_price": "tuan_price",
                "goods_price_origin": "origin_price",
                "coupon_money": "coupon_money",
                "goods_freight": "freight",
                "goods_commission": "commission",
                "goods_price": "goods_price",
                "goods_price_pay": "goods_price_pay",
                "create_time": "create_time",
                "cate_type_goods_sort": "cate_type_goods_sort"
            };

            if (data.order) {
                this.filterData.sort_field = sortFieldMap[data.prop];
                this.filterData.sort_type = sortTypeMap[data.order];
            } else {
                this.filterData.sort_field = '';
                this.filterData.sort_type = '';
            }

            this.getTableData();
        },
        fnPushJingang(){
            if(this.checkedJingang.length <= 0){
                this.$message({
                    type: 'warning',
                    message: '请选择推荐栏目',
                    center: true
                });
                return ;
            }
            let goods_nos = this.multipleSelection.map(val => {
                return val.goods_no;
            });

            this.$post('/student/shop_goods%5Cjoin_cate', {
                goods_no_json: JSON.stringify(goods_nos),
                cate_no_json: JSON.stringify(this.checkedJingang)
            }, resp => {
                if(resp.code == 1){
                    this.checkedJingang = [];
                    this.showJingangDialog = false;
                    this.$message({
                        type: 'success',
                        message: '添加成功'
                    });
                }else{
                    this.$message({
                        type: 'warning',
                        message: resp.msg || '添加失败'
                    });
                }
            });
        },
        fnShowPushDialog(){
            // this.checkedJingang = [];
            // this.showJingangDialog = true;
            this.$refs.shopGroup.show();
            this.$refs.shopGroup.getType('add');
        },

        /**
         * 获取推荐到商品组数据
         */
        getData (resp) {
            // console.log(resp);
            // console.log(this.multipleSelection);
            if(resp.type == 'add') {
                let goods_no = this.multipleSelection.reduce((cur,next) => {
                    cur.push(next.goods_no);
                    return cur;
                },[]);

                this.$post('/student/shop_goods%5Cjoin_cate', {
                    goods_nos: goods_no.join(),
                    data_nos: resp.data.join()
                }, resp => {
                    if (resp.code == 1) {
                        this.$refs.shopGroup.hide();
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            }

            if(resp.type == 'edit') {
                this.$post('/student/shop_goods%5Cset_cate', {
                    goods_nos: resp.goods_no,
                    data_nos: resp.data.join()
                }, resp => {
                    if (resp.code == 1) {
                        this.$refs.shopGroup.hide();
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '编辑成功'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            }
        },

        /**
         * 编辑商品组
         */
        fnEditGroup (row) {
            this.$post('/student/shop_goods%5Ccurrent_cate', {
                goods_no: row.goods_no
            }, resp => {
                if (resp.code == 1) {
                    if(Object.prototype.toString.call(resp.data) !== '[object Null]' && resp.data.list.length > 0) {
                        this.$refs.shopGroup.getType('edit', {
                            data: resp.data,
                            goods_no: row.goods_no
                        });
                        this.$refs.shopGroup.show();
                    } else {
                        this.$message({
                            type: 'warning',
                            message: '该商品还没有设置商品组分类'
                        });
                        return false;
                    }
                } else {
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 移出商品组
         */
        fnRemoveGroup (row) {
            this.$confirm('是否将该商品移出该商品组及其以下所有的分类？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/shop_goods%5Cquit_cate', {
                    goods_nos: row.goods_no,
                    data_nos: this.$route.query.sub_type_no
                }, resp => {
                    if (resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            });
        },

        /**
         * 移除分类组
         */
        fnRemoveGroupChild (row) {
            this.$confirm('是否将该商品移出此商品组分类？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/shop_goods%5Cquit_cate', {
                    goods_nos: row.goods_no,
                    data_nos: this.$route.query.cate_type_no
                }, resp => {
                    if (resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            });
        },

        /**
         * 批量移出商品组/商品分类
         *      groupType  1:商品组  2:商品分类
         */
        fnDeleteGroup () {
            let goods_nos = this.multipleSelection.reduce((cur,next) => {
                cur.push(next.goods_no);
                return cur;
            }, []);

            if(this.groupType == 1) {
                this.$confirm('是否将选中的商品移出该商品组及其以下所有的分类？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$post('/student/shop_goods%5Cquit_cate', {
                        goods_nos: goods_nos.join(),
                        data_nos: this.$route.query.sub_type_no
                    }, resp => {
                        if (resp.code == 1) {
                            this.getTableData();
                            this.$message({
                                type: 'success',
                                message: '操作成功'
                            });
                        } else {
                            this.$message({
                                type: 'warning',
                                message: resp.msg
                            });
                        }
                    });
                });
            } else if (this.groupType == 2) {
                this.$confirm('是否将选中的商品移出该商品组分类？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$post('/student/shop_goods%5Cquit_cate', {
                        goods_nos: goods_nos.join(),
                        data_nos: this.$route.query.cate_type_no
                    }, resp => {
                        if (resp.code == 1) {
                            this.getTableData();
                            this.$message({
                                type: 'success',
                                message: '操作成功'
                            });
                        } else {
                            this.$message({
                                type: 'warning',
                                message: resp.msg
                            });
                        }
                    });
                });
            } else {
                return false;
            }
        },

        /**
         * 批量上架/下架
         */
        fnShowPushUpper (type) {
            let selected = this.multipleSelection.map(val => {
                return val.goods_no;
            });

            this.$post('/student/shop_goods%5Cset_status_batch', {
                goods_no_json: JSON.stringify(selected),
                status: type
            }, resp => {
                if (resp.code == 1) {
                    this.getTableData(1);
                    this.$message({
                        type: 'success',
                        message: '操作成功'
                    });
                } else {
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },
        fnGoAcquisitoin(){
            this.$router.push({
                name: 'goodsCollect'
            });
        },
        fnGoWorkBrowse (param) {
            let name = param == 1 ? 'shopBrowse' : 'shopVolumnBrowse';

            this.$router.push({
                name: name
            });
        },
        removeJingang(goods_no){
            this.$confirm('确认要将该商品从当前金刚区移除?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/shop_goods%5Cquit_cate', {
                    goods_no_json : JSON.stringify([goods_no]),
                    cate_no_json : JSON.stringify([this.filterData.selectedType[1]])
                }, resp => {
                    if(resp.code == 1){
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    }else{
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '操作失败'
                        });
                    }
                });
            }).catch(() => {
            });

        },
        fnGetSpec(good){
            this.$post('/student/shop_goods%5Cget', {
                goods_no: good.goods_no
            }, resp => {
                if(resp.code == 1){
                    let spec = resp.data.goods_product_list;

                    this.$set(good, 'specList', spec);
                    console.log(good.specList);
                }else{
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },
        async fnAudit(item, status){
            let reason = 'eeee';

            try{
                await new Promise((resolve, reject) => {
                    if(status == -1){
                        this.$prompt('请输入不通过原因', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            inputPattern: /\S/,
                            inputErrorMessage: '请输入不通过原因'
                        }).then(({ value }) => {
                            reason = value;
                            resolve();
                        }).catch(() => {
                            reject();
                        });
                    }else{
                        resolve();
                    }
                });
                this.$post('/student/shop_goods%5Caudit', {
                    action: status == 1 ? 'pass' : 'fail',
                    goods_no: item.goods_no,
                    reason: reason
                }, resp => {
                    if (resp.code == 1) {
                        this.$set(item, 'audit_status', status);
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                        this.getTableData();
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '操作失败'
                        });
                    }
                });
            }catch(e){
                console.log('cancel');
            }
        },

        /**
         * 批量审核通过
         */
        fnAudiSuccess () {
            this.multipleSelection.forEach(option => {
                this.$post('/student/shop_goods%5Caudit', {
                    action: 'pass',
                    goods_no: option.goods_no
                }, resp => {
                    if (resp.code == 1) {
                        //
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '操作失败'
                        });
                    }
                });
            });

            setTimeout(()=>{
                this.$message({
                    type: 'success',
                    message: '审核通过'
                });
                this.getTableData();
            },500);
        },

        /**
         * 问答
         */
        fnJump (no) {
            this.$router.push({
                name: 'shopQuestion',
                query: ({
                    goods_no: no,
                    page: this.page.now_page,
                    filterData: JSON.stringify(this.filterData)
                })
            });
        },

        /**
         * 跳转商品详情页
         */
        fnGoShoplist (row) {
            if (row.goods_url !== '' && row.goods_type !== 1) {
                window.open(row.goods_url);
                return;
            }

            if(row.goods_url == '' && (row.goods_type !== 1 && row.goods_type !== 8)) {
                this.$message({
                    type: 'warning',
                    message: '链接不可以为空'
                });
                return;
            }

            if(row.goods_type == 1 || row.goods_type == 8) {
                const routeData = this.$router.resolve({
                    name: 'goodsDetail',
                    query: {
                        no: row.goods_no
                    }
                });

                window.open(routeData.href, '_blank');
                // v2.0.7改为总后台商品详情
                /*this.$post('/wei4/hire_user%5Cget_login_session_ticket', {
                    hire_no: row.hire_no
                }, resp => {
                    if (resp.code == 1) {
                        // window.open('http://0.0.0.0/manage/market/good-edit?no=' + row.goods_no );
                        if(window.location.host == 'phaadmin.wxhand.com') {
                            window.open('http://cms.zsdx.cn/manage/market/good-edit-group?no=' + row.goods_no + '&session_ticket=' + resp.data.session_ticket);
                        }else{
                            window.open('http://gt.wxhand.com/manage/market/good-edit-group?no=' + row.goods_no + '&session_ticket=' + resp.data.session_ticket);
                        }
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg,
                            center: true
                        });
                    }
                });*/
            }

        },

        /**
         * 重置
         */
        fnReset () {
            let list = JSON.stringify(this.filterData);
            let newList = JSON.parse(list);

            // this.ification = '';
            this.volume = this.autoinc_view_set = this.school_filter_status = 99;
            for(let i in newList){
                newList[i] = '';
            }

            this.filterData = {
                ...newList
            };
            this.getTableData(1);
        },

        /**
         * 导入淘客
         */
        fnImport () {
            this.showAddDialog = !this.showAddDialog;
        },

        /**
         * 近期添加
         */
        // fnfutureAdd () {},

        /**
         * 提交淘客数据
         */
        submitForm (formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.$post('/student/shop_goods_collect%5Cimport', {
                        content: this.ruleForm.url,
                        shop_no: this.ruleForm.shop_no,
                        type_no: this.ruleForm.fication[1],
                        shop_social_type: this.ruleForm.shop_social_type
                    }, resp => {
                        this.showAddDialog = !this.showAddDialog;
                        if (resp.code == 1) {
                            this.getTableData(1);
                            this.$message({
                                type: 'success',
                                message: '导入成功'
                            });
                        } else if (resp.code == 0) {
                            this.$message({
                                type: 'warning',
                                message: resp.msg
                            });
                        }
                    });
                }
            });
        },

        /**
         * 店铺搜索
         */
        fnSearchShop(word) {
            if(word != '') {
                this.loading = true;
                this.$post('/student/shop%5Csuggest', {
                    keyword: word
                }, resp => {
                    if (resp.code == 1) {
                        this.shopListChoose = resp.data.list;
                    }
                });
                this.loading = false;
            }else{
                this.shopListChoose = [];
            }
        },
        handleSelect(no) {
            this.shopListChoose.map((item, index) => {
                if(item.shop_no == no) {
                    this.ruleForm.shop_logo = item.shop_logo;
                }
            });
        },
        /**
         * 查看素材库
         * @param row
         */
        goMaterialList(row) {
            let routeData = this.$router.resolve({
                name: 'materialLibrary',
                query: {
                    goods_no: row.goods_no
                }
            });

            window.open(routeData.href, '_blank');
        },

        /**
         * @description 查看图片
         * @param   {String}    images    单图预览
         * @param   {Array}     images     多图预览
         */
        fnShowPreview(images) {
            if(images && Object.prototype.toString.call(images) == '[object String]') {
                this.$refs.preview.show([
                    images
                ]);
            } else if (images && Object.prototype.toString.call(images) == '[object Array]') {
                this.$refs.preview.show(images);
            } else {
                this.$notify({
                    title: '提示',
                    message: '图片类型错误',
                    type: 'warning',
                    duration: 2000
                });
            }
        },

        /**
         * 每页条数更改
         * @param page_size
         */
        handleSizeChange(page_size) {
            this.page.page_size = page_size;
            this.getTableData();
        },
    }
};
</script>

<style lang="less" scoped>
  .container {
    display: flex;
    flex-direction: column;
    width: calc(100% - 24px);
      margin: 12px;
  }
  .data-table {
      ::-webkit-scrollbar {
          width: 6px;
          height: 6px;
      }
      // 操作按钮
      .option-btn-group {
          .el-button {
              margin-left: 0;
              margin-right: 10px;
              margin-top: 12px;
          }
      }
      .goods-info {
          display: flex;
          align-items: center;
          .goods-cover {
              width: 86px;
              height: 86px;
              cursor: pointer;
              margin-right: 16px;
          }
          .info {
              display: flex;
              flex-direction: column;
              justify-content: space-between;
              font-size: 12px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #333333;
              .goods-info__title {
                  font-size: 14px;
                  cursor: pointer;
                  color: #409EFF;
                  display: -webkit-box;
                  overflow: hidden;
                  -webkit-line-clamp: 2;
                  /*! autoprefixer: off */
                  -webkit-box-orient: vertical;
              }
          }
      }
  }
  .container-header {
    width: 100%;
    background-color: #fff;
      .header-goods-list {
          height: 72px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: 0 12px;
          border-bottom: 1px solid #EBEEF5;
          .header-title {
              font-size: 18px;
              font-family: PingFangSC-Medium, PingFang SC;
              font-weight: 500;
              color: #333333;
              padding-left: 20px;
              position: relative;
              &:before {
                  content: "";
                  display: block;
                  width: 3px;
                  height: 18px;
                  background: #1890FF;
                  position: absolute;
                  top: 50%;
                  left: 12px;
                  transform: translateY(-50%);
              }
          }
          .opt-btn-group {
              display: flex;
              .opt-btn-item {
                  padding: 0 24px;
                  height: 48px;
                  font-size: 14px;
                  font-family: PingFangSC-Medium, PingFang SC;
                  font-weight: 500;
                  color: #1890FF;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  cursor: pointer;
                  border-left: 1px solid #F0F2F5;
                  &:first-of-type {
                      border: 0;
                  }
                  &:hover {
                      background: #F9F9F9;
                      transition: all 0.2s;
                  }
              }
          }
      }
  }
  /*筛选*/

  .filter-view {
      box-sizing: border-box;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      padding: 12px 24px 0;
      background: #fff;

      .header-new-box {
          display: flex;
          align-items: center;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #333333;
          white-space: nowrap;
          margin-right: 24px;
          margin-bottom: 12px;

          &-title {
              margin-right: 16px;
              white-space: nowrap;
          }
          .query-btn {
              width: 68px;
              height: 36px;
              background: #FFFFFF;
              border-radius: 4px;
              border: 1px solid #1890FF;
              font-size: 14px;
              font-family: PingFangSC-Medium, PingFang SC;
              font-weight: 500;
              color: #1890FF;
              display: flex;
              align-items: center;
              justify-content: center;
              cursor: pointer;
          }
      }
  }
  /deep/ .el-radio-button {
      &.is-active {
          .el-radio-button__inner {
              background: #E6F1FC;
              color: #20A0FF;
              border-color: #20A0FF;
          }
      }
  }
  .operation-wrapper {
    display: flex;
    flex-wrap: wrap;
    padding: 12px 23px 2px 23px;
    overflow-x: auto;
    .el-form-wrap {
        transition: all 1s;
    }
    .el-form-flod {
        height: 40px;
        overflow: hidden;
    }
    .buttons {
      width: auto;
      display: flex;
      align-items: center;
    }
    .search-wrapper {
      flex: 1;
    }
    .filter-item {
      margin-bottom: 15px;
      display: flex;
      margin-right: 15px;
      .number-input {
          width: 150px;
      }
      .el-form-item {
        margin-bottom: 0;
      }
      .el-autocomplete {
        width: 100%;
      }
    }
    .search-btn-wrapper {
      margin-bottom: 15px;
    }

    .el-button {
      margin-left: 10px;
      margin-bottom: 10px;
    }
  }
  .number-input-number {
      width: 130px;
  }
  .content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .table-wrapper {
    flex: 1;
    overflow: hidden;
    background-color: #fff;
    // .shop-list-name {
    //     cursor: pointer;
    //     &:hover {
    //         color: #409EFF;
    //     }
    // }
    .submit-config-item {
      display: inline-block;
      position: relative;
      padding-right: 10px;
      font-size: 14px;

      & + .submit-config-item {
        padding-left: 10px;
        &::before {
          content: "";
          position: absolute;
          top: 50%;
          left: 0;
          width: 1px;
          height: 14px;
          transform: translate(0, -50%);
          background-color: #d8d8d8;
        }
      }

      .num {
        vertical-align: middle;
      }
      .iconfont {
        font-size: 16px;
        color: #b9b9b9;
        vertical-align: middle;
      }

      .icon-tupian {
        font-size: 20px;
      }
    }
    .task-review-status {
      .status {
        position: relative;
        display: inline-block;
        padding-left: 9px;
        &::before {
          content: "";
          position: absolute;
          top: 50%;
          left: 0;
          transform: translate(0, -50%);
          width: 6px;
          height: 6px;
          border-radius: 50%;
        }
        &.wait-submit,
        &.wait-audit {
          &::before {
            background-color: #f5a623;
          }
        }
        &.deny {
          &::before {
            background-color: #ff0019;
          }
        }
        &.completed {
          &::before {
            background-color: #00c800;
          }
        }
      }
    }
    .el-button {
      padding: 0;
    }

    .btn-delete {
      color: #fd4d32;
      &.is-disabled {
        color: #c0c4cc;
        cursor: not-allowed;
      }
    }
    .zd-btn-text {
        margin-left: 0px;
        margin-right: 2px;
    }
  }
  .pagination-wrapper {
    cursor: pointer;
    display: flex;
    height: 60px;
    background: #fff;
    align-items: center;
    white-space: nowrap;
    padding: 10px 12px;
    justify-content: space-between;
    .el-pagination {
      float: right;
      padding: 0;
      background-color: transparent;
    }
    .el-pagage-wrap {
        display: flex;
        width: 100vw;
        height: 32px;
        align-items: center;
        justify-content: space-between;
        .el-page-box {
            display: flex;
            height: 32px;
            align-items: center;
            .el-pagage-cont {
                display: flex;
                height: 32px;
                align-items: center;
                margin-left: 20px;
                .el-pagage-cursor {
                    color: #20a0ff !important;
                    cursor: pointer;
                }
            }
        }
    }
  }
  .el-form {
    .el-progress {
      display: inline-block;
      width: 150px;
      margin-right: 15px;
      vertical-align: middle;
    }
    .progress-hint {
      color: #8c8c8c;
    }
  }
  .form-operation-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 56px;

    .index-btn {
      color: #000;
      cursor: pointer;
      & + .index-btn {
        margin-left: 15px;
      }
      &.is-disabled {
        color: #c0c4cc;
        cursor: not-allowed;
      }
    }
  }
  .dialog-input-label {
    margin-bottom: 10px;
  }
    //打标签
    .content-dialog {
        padding-bottom: 30px;
        .dialog-footer {
            width: 100%;
            display: flex;
            justify-content: center;
        }
    }
    .label-input {
      width: 100%;
      margin-top: 15px;
    }
    .label-button {
        width: 57px;
        border-left: none;
    }
    .label-searchTitle {
        display: flex;
        align-items: center;
    }
    .label {
        margin: 15px 0 0px 0;
        .el-tag {
            margin-right: 10px;
            margin-bottom: 15px;
            cursor: pointer;
        }
        .button-new-tag {
            margin-left: 10px;
            height: 24px;
            line-height: 24px;
            padding-top: 0;
            padding-bottom: 0;
        }
    }
    .label-tips {
        height: 160px;
        width: 100%;
        color: #606266;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .label-default{
        max-height: 400px;
        overflow-y: auto;
        &::-webkit-scrollbar {
            width: 4px;
            border-radius: 10px;
        }
        .label-cont {
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
        }
        .label-title {
            font-size: 14px;
            color: #3F454B;
            margin-top: 30px;
            margin-bottom: 15px;
        }
        .label-refresh {
            font-size: 13px;
            color: #88909C;
        }
        .el-tag {
            margin-right: 10px !important;
            margin-bottom: 15px !important;
            cursor: pointer;
        }
    }
    .el-recomon-button {
        border: none;
        background: transparent;
        margin-left: -20px;
    }
    .el-type-name {
        display: flex;
        align-items: center;
    }
    .school-list {
        max-height: 310px;
        overflow: auto;
        .empty {
            text-align: center;
            color: #7e8993;
        }
    }
    .submit-btn {
        margin: 30px auto 0;
        display: block;
    }
    .el-tag-school {
        display: flex;
        width: 100%;
        flex-wrap: wrap;
        margin-bottom: 10px;
        .el-tag{
            margin-right: 10px;
            margin-bottom: 10px;
            height: 32px;
            display: flex;
            align-items: center;
        }
    }
    .el-school-filter {
        display: flex;
        height: 32px;
        align-items: center;
        margin-top: 15px;
    }
    .cursor-font {
      color: #409EFF !important;
      cursor: pointer;
    }
    .reduction_price {
        color: #FF3030;
        font-size: 14px;
        box-sizing: border-box;
        border: 1px #FF3030 solid;
        border-radius: 4px;
        padding: 7px 5px;
    }
    /deep/ .el-table__fixed-right {
        right: 6px!important;
    }
  /deep/ .el-dialog__header {
      padding-top: 10px;
      box-shadow: 0 1px 0 0 rgba(233, 233, 233, 1);
      display: flex;
      align-items: center;
      background: #FAFAFA;
      border-radius: 4px 4px 0 0;

      .el-dialog__title {
          font-weight: 500;
          color: #333;
          font-size: 14px;
      }

      .el-icon-close:before {
          color: rgb(194, 194, 194);
          font-size: 17px;
          font-weight: bold;
      }

      .el-dialog__headerbtn {
          top: 14px;
      }
  }

  /deep/ .el-textarea__inner {
      resize: none;
  }
</style>
<style lang="less">
  .main .goods-list-container .operation-wrapper .filter-item {
      width: auto;
      flex-wrap: wrap;
  }
  .goods-list-container {
    .filter-input {
      width: 100% !important;
    }
    .small-form {
      font-size: 0;
    }
    .el-dialog__body {
      padding-bottom: 0;
      padding-top: 10px;
    }
    .small-form-item {
      display: inline-block;
      width: 47%;
      font-size: 14px;
      margin-right: 10%;
      &:nth-child(even) {
        margin-left: 6%;
      }
      .el-form-item__label {
        padding-right: 5px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
    tbody {
      .cell {
        display: flex;
        align-items: center;
        padding-top: 0;
        padding-bottom: 0;
        height: auto;
      }
    }
  }

  .cate-area-item{
      margin-bottom: 15px;
      margin-left: 0!important;
      margin-right: 20px;
  }
  .img-cover{
      width: 50px;
      height: 50px;
  }
  .goods-list-container .el-dialog__body {
      padding-bottom: 30px !important;
  }
  .main .shopAdd_result .shop_tips_title {
      width: 100%;
      height: 30px;
      line-height: 30px;
  }
  .shopAdd_result .el-dialog .el-dialog__body {
    max-height: 650px !important;
    overflow-y: auto;
    &::-webkit-scrollbar{
        width: 3px;
    }
    .shop_addInfo_sucess {
        color: #409EFF;
    }
    .shop_addInfo_error {
        color: #fd4d32;
    }
}
.goods-list-container tbody .cell {
    height: auto !important;
}
    .school-list {
        .el-checkbox-button {
        margin-right: 10px;
        margin-bottom: 10px;
        border-radius: 0;
        }
        .el-checkbox-button:first-child .el-checkbox-button__inner {
            border-radius: 2px;
        }
        .el-checkbox-button__inner {
            border-left: 1px solid #dcdfe6;
            font-size: 12px;
            font-weight: 400;
            color: rgba(126, 137, 147, 1);
            border-radius: 2px;
            position: relative;
        }
        .el-checkbox-button.is-checked .el-checkbox-button__inner {
            background-color: #fff;
            border: 1px solid rgba(32, 160, 255, 1);
            color: #20a0ff;
            box-shadow: none;
            overflow: hidden;
            &::after {
                content: " ";
                position: absolute;
                bottom: 0;
                right: 0;
                width: 24px;
                height: 18px;
                background-image: url(//cdn.zsdx.cn/admin/images/common/checked.png);
                background-position: center;
                background-size: cover;
                background-repeat: no-repeat;
            }
        }
    }
</style>
